twitter

Tweepy: How can I look up more than 100 user screen names

只愿长相守 提交于 2019-12-25 09:41:04
问题 You can only retrieve 100 user objects per request with the api.lookup_users() method. Is there an easy way to retrieve more than 100 using Tweepy and Python? I have read this post: User ID to Username tweepy but it does not help with the more than 100 problem. I am pretty novice in Python so I cannot come up with a solution myself. What I have tried is this: users = [] i = 0 num_pages = 2 while i < num_pages: try: # Look up a collection of ids users.append(api.lookup_users(user_ids=ids[100*i

How to download twitter feed

夙愿已清 提交于 2019-12-25 09:26:06
问题 I am quite the novice when it comes to coding. How do I modify this sample code to download tweets using Python? def get_tweets(api, input_query): for tweet in tweepy.Cursor(api.search, q=input_query, lang="en").items(): yield tweet if __name__ == "__version__": input_query = sys.argv[1] access_token = "REPLACE_YOUR_KEY_HERE" access_token_secret = "REPLACE_YOUR_KEY_HERE" consumer_key = "REPLACE_YOUR_KEY_HERE" consumer_secret = "REPLACE_YOUR_KEY_HERE" auth = tweepy.OAuthHandler(consumer_key,

Multiproccessing twitter api calls using python

浪子不回头ぞ 提交于 2019-12-25 09:17:39
问题 I want to do multiproccesing on twitter search API. I have got the code below and it do 1 call every time instead of multiproccesing. from multiprocessing import Process from twitter import * config = {} exec(compile(open("config.py", "rb").read(), "config.py", 'exec'), config) twitter = Twitter( auth=OAuth(config["access_key"], config["access_secret"], config["consumer_key"], config["consumer_secret"])) def twitterSearch(word): tweetsWithWord = twitter.search.tweets(q=word, count=100) print

Python Regex expression for extracting hashtags from text

此生再无相见时 提交于 2019-12-25 09:17:08
问题 I'm processing some tweets I mined during the election and I need to a way to extract hashtags from tweet text while accounting punctuation, non-unicode characters, etc while still retaining the hashtag in the outputted list. For example, the orignal text from a tweet looks like: I'm with HER! #NeverTrump #DumpTrump #imwithher🇺🇸 @ Williamsburg, Brooklyn and when turned into a string in python (or even put into a code block on this site), the special characters near the end are changed,

Error 'Missing required parameter : grant_type' using Swift 3

本小妞迷上赌 提交于 2019-12-25 08:59:40
问题 I am working on Twitter API and I want to get access_Token but I am getting this error: { "errors" : [ { "message" : "Missing required parameter: grant_type", "label" : "forbidden_missing_parameter", "code" : 170 } ] }. My request is below: let dict = ["grant_type" : "client_credentials"] requestPOSTURL("https://api.twitter.com/oauth2/token", params: dict as [String : AnyObject] , headers: ["Authorization" : "Basic " + strHeader, "Content-Type" : "application/x-www-form-urlencoded;charset=UTF

Playframework and Twitter Streaming API

*爱你&永不变心* 提交于 2019-12-25 08:57:22
问题 How to read response data from Twitter Streaming API - POST statuses/filter ? I have established connection and I receive 200 status code, but I don't know how to read tweets. I just want to println tweets as they coming. ws.url(url) .sign(OAuthCalculator(consumerKey, requestToken)) .withMethod("POST") .stream() .map { response => if(response.headers.status == 200) println(response.body) } EDIT: I found this solution ws.url(url) .sign(OAuthCalculator(consumerKey, requestToken)) .withMethod(

How to check if a timestamp is an hour old?

爱⌒轻易说出口 提交于 2019-12-25 08:54:01
问题 I am building a caching system to store Twitter API tweets as to avoid violating the hourly call limit. I am storing the tweets in a database with a timestamp and then checking in PHP to see if the timestamp is an hour old, if so then I call the API again. At the moment I can't seem to get it working. Here is what I curently have (which I admit is most probably wrong!) if($results->tweet_date <= strtotime('-1 hours')) { //do api call } else { //call tweets from database } This doesn't seem to

Twitter follow button doesn't render in Google Chrome

筅森魡賤 提交于 2019-12-25 08:49:55
问题 I have used the twitter button resources to generate code for a follow button, which I added to the required page of a website I am working on. The code is: <a href="https://twitter.com/daniduffymakeup" class="twitter-follow-button" data-show-count="false" data-size="large">@daniduffymakeup</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs)

Dynamically changing data-text on twitter widget

眉间皱痕 提交于 2019-12-25 08:16:06
问题 I generate content for my tweet button as the page loads, but even when I have my script to run first widget.js still runs before, I tried using twttr.widget.load() to update the value but it didn't work. Is it possible to update the value of the twitter button after it has already loaded initially? Or make it so it initializes after the content has loaded? Below is the code I use. I've tried placing widget.js before and after my script on the HTML too. text = quote[0].content.substring(3,

Execution Error, return code 1 while executing query in hive for twitter sentiment analysis

我的未来我决定 提交于 2019-12-25 08:07:14
问题 I am doing twitter sentiment analysis using hadoop, flume and hive. I have created the table using hive -f tweets.sql tweets.sql --create the tweets_raw table containing the records as received from Twitter SET hive.support.sql11.reserved.keywords=false; CREATE EXTERNAL TABLE Mytweets_raw ( id BIGINT, created_at STRING, source STRING, favorited BOOLEAN, retweet_count INT, retweeted_status STRUCT< text:STRING, user:STRUCT<screen_name:STRING,name:STRING>>, entities STRUCT< urls:ARRAY<STRUCT