-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
…r npm lib.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
node_modules/ | ||
package-lock.json |
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
#Twitter Miner | ||
Tweets miner service to populate the KeepCalm training database | ||
Tweets miner service to populate the KeepCalm training database | ||
|
||
### Twitter API Documentation | ||
https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets.html |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Created by maiquel on 22/01/18. | ||
*/ | ||
|
||
(function () { | ||
"use strict"; | ||
|
||
let Twitter = require('twitter'), | ||
properties = require('./properties'); | ||
|
||
let client = new Twitter({ | ||
consumer_key: properties.TWITTER_KEY, | ||
consumer_secret: properties.TWITTER_SECRET, | ||
access_token_key: properties.TWITTER_TOKEN, | ||
access_token_secret: properties.TWITTER_TOKEN_SECRET | ||
}); | ||
|
||
let params = { | ||
q: properties.HANGRY_WORDS.join(" OR "), | ||
tweet_mode: 'extended', | ||
count: 100, | ||
|
||
}; | ||
|
||
let count = 0; | ||
|
||
getTweets(params); | ||
|
||
function getTweets(params, next_id) { | ||
params.max_id = next_id; | ||
client.get('search/tweets', params, (err, tweets, response) => { | ||
if (err) { | ||
console.log(err); | ||
} | ||
else { | ||
// remove retweets | ||
let curTweets = tweets.statuses.filter(function (tweet) { | ||
return !tweet.full_text.includes("RT @"); | ||
}); | ||
|
||
curTweets.forEach((tweet) => { | ||
console.log(tweet.full_text + "\n" + tweet.id + "\n ################################"); | ||
count++; | ||
}); | ||
|
||
try { | ||
let next_result = tweets.search_metadata.next_results.split("max_id=")[1].split("&")[0]; | ||
console.log("\n\n\n\n" + count + "\n\n\n\n"); | ||
getTweets(params, Number(next_result)); | ||
} | ||
catch (ex) { | ||
console.log("\n\n\n\n\nTerminou com " + count + " Tweets encontrados."); | ||
|
||
} | ||
} | ||
}) | ||
} | ||
|
||
}()); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,12 @@ | |
"description": "Tweets miner to the KeepCalm training database", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"start": "node index.js" | ||
}, | ||
"author": "Maiquel Jardel Ludwig ([email protected])", | ||
"license": "ISC" | ||
"license": "ISC", | ||
"dependencies": { | ||
"twitter": "^1.7.1" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Created by maiquel on 24/03/17. | ||
*/ | ||
|
||
(function () { | ||
"use strict"; | ||
|
||
/* Server Settings */ | ||
exports.SERVER_PORT = 8082; | ||
|
||
/* Twitter Authentication */ | ||
exports.TWITTER_KEY = 'BxiQLE4OPPmmRvgw5aC9yKqST'; | ||
exports.TWITTER_SECRET = 'LJSKJESeB7NV9SxBbe7QmYVl9bqMpQIIiZKnHDSltQYsUDlliI'; | ||
exports.TWITTER_TOKEN = '1539136728-7L8QdVnN0y2BKJ4nJjRtuxwONRBsIHiSXyjHFgM'; | ||
exports.TWITTER_TOKEN_SECRET = 'mOauAa9SJEOjmF2JQWiYVqn8ijwMHbsFsEK3kRYRVEJNs'; | ||
|
||
exports.HANGRY_WORDS = [ | ||
'fdp', | ||
'caralho', | ||
'merda', | ||
'bosta', | ||
'porra', | ||
'puta' | ||
] | ||
|
||
}()); |