Skip to content

Instantly share code, notes, and snippets.

@fayimora
Created November 22, 2013 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fayimora/7600249 to your computer and use it in GitHub Desktop.
Save fayimora/7600249 to your computer and use it in GitHub Desktop.
Code to fetch data from twitter. Written in Coffeescript. Stores data to a mongodb database.q
twitter = require('ntwitter')
mongo = require('mongodb')
user = process.env.MONGO_USER
password = process.env.MONGO_PASSWORD
dbHost = "127.0.0.1"
dbPort = mongo.Connection.DEFAULT_PORT
db = new mongo.Db("tweets", new mongo.Server(dbHost, dbPort, {}))
auth = new twitter(
consumer_key: '',
consumer_secret: '',
access_token_key: '',
access_token_secret: ''
)
console.log "Done authenticating with Twitter!"
tweetsCollection = ""
db.open (err) ->
db.collection "apple_tweets", (err, collection) ->
console.log "Connected to #{dbHost}:#{dbPort}"
tweetsCollection = collection
console.log "tweetsCollection is #{tweetsCollection}"
auth.stream 'statuses/filter',
'track': ['apple', 'ipad', 'ipod', 'mac', 'imac', 'iphone'], (stream) ->
stream.on "data", (data) ->
if data.lang == "en"
tweetsCollection.insert data, (error) ->
console.log error if error
@fayimora
Copy link
Author

f = open(id)

@bigmeech
Copy link

bigmeech commented Jun 8, 2022

Eeww

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment