Skip to content

Instantly share code, notes, and snippets.

View revox's full-sized avatar

Andy Freeman revox

View GitHub Profile
@revox
revox / tweetatron_tags_style.py
Last active December 3, 2020 14:22
Python code to produce a TAGS style output from Twitter Streaming API
import twitter, json, csv
# == OAuth Authentication ==
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
OAUTH_TOKEN = ''
OAUTH_TOKEN_SECRET = ''
auth = twitter.oauth.OAuth(OAUTH_TOKEN,
OAUTH_TOKEN_SECRET,
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Basic responsive template</title>
<style>
/* a centred div with a maximum width */
/* if you want really nice fonts use a Google font */
.container {
max-width: 600px;
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Centred Column</title>
<style>
.container {
max-width: 600px;
margin: 0 auto;
@revox
revox / twitter_streaming_follow.py
Last active November 10, 2020 09:02
sixohsix Twittter lib doing a follow on a couple of news accounts
# Finding topics of interest by using the filtering capablities it offers.
import twitter, json, sys, csv
# == OAuth Authentication ==
# The consumer keys can be found on your application's Details
# page located at https://dev.twitter.com/apps (under "OAuth settings")
# this app is being run by cast laboratory..@CASTlaboratory (4003669463)
consumer_key=""
consumer_secret=""
import nltk, sys, csv
from nltk.tokenize import TweetTokenizer
from nltk.corpus import stopwords
from datetime import datetime
import pandas as pd
import numpy as np
import string
from collections import Counter
import twitter, json, sys, csv
# == OAuth Authentication ==
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
OAUTH_TOKEN = ''
OAUTH_TOKEN_SECRET = ''
auth = twitter.oauth.OAuth(OAUTH_TOKEN,
OAUTH_TOKEN_SECRET,
@revox
revox / mymaps_javascript.html
Created December 2, 2016 09:34
Starting point for JavaScript version of Google marker map (My Maps). You need an API key and the ID of your MyMap.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Simple Marker Map using Google Maps JavaScript API</title>
<style>
html,
body,
#map-canvas {
'''Tweet Streaming API consumer'''
import twitter, csv, sys
# == OAuth Authentication ==
consumer_key=""
consumer_secret=""
access_token=""
access_token_secret=""
@revox
revox / twitter_user_timeline.py
Last active December 15, 2015 12:01
Get a Twitter users timeline up to 3,200 tweets written into a CSV, uses sixohsox Twitter modules retry facitlity (30 second sleep) if your rate limited
# dont keep this script in public_html!!!!
import twitter, sys,json,csv, time
def twitter_user_timeline(twitter_api, q):
''' get last tweet ID so we can paginate down from that 200 at a time to 3,200
'''
user_timeline = twitter_api.statuses.user_timeline(screen_name=q,count=1)
print user_timeline[0]['id']
ids = [user_timeline[0]['id']]
statuses = []
@revox
revox / twitter_search_api_writer.py
Last active December 15, 2015 12:09
Twitter search API (last 7 days) into a CSV file with some profile info from the tweets (based on code from MTSW, 2nd ed, example 9.4)
# dont keep this script in public_html!!!!
import twitter
import sys,json,csv
def twitter_search(twitter_api, q, max_results=200):
# See https://dev.twitter.com/docs/api/1.1/get/search/tweets and
# https://dev.twitter.com/docs/using-search for details on advanced
# search criteria that may be useful for keyword arguments
# See https://dev.twitter.com/docs/api/1.1/get/search/tweets