tweepy

how to take all tweets in a hashtag with tweepy?

那年仲夏 提交于 2019-12-03 05:10:47
I'm trying to take every open tweets in a hashtag but my code does not go further than 299 tweets. I also trying to take tweets from a specific time line like tweets only in May 2015 and July 2016. Are there any way to do it in the main process or should I write a little code for it? Here is my code: # if this is the first time, creates a new array which # will store max id of the tweets for each keyword if not os.path.isfile("max_ids.npy"): max_ids = np.empty(len(keywords)) # every value is initialized as -1 in order to start from the beginning the first time program run max_ids.fill(-1) else

Error while fetching Tweets with Tweepy

情到浓时终转凉″ 提交于 2019-12-03 03:42:48
I have a Python script that fetch tweets. In the script i use the libary Tweepy . I use a valid authentication parameters. After running this script some tweets are stored in my MongoDB and some are refused by the if statement. But still i get the error requests.packages.urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(0 bytes read, 2457 more expected)' My question is which part of the script can i improve, so i do not get the error above. This is my script from tweepy import Stream from tweepy import OAuthHandler from tweepy.streaming import StreamListener import time

Parsing JSON fails as strings appear instead of dicts/lists [closed]

[亡魂溺海] 提交于 2019-12-02 16:04:32
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . with open('twit/example.json', encoding='utf8') as json_data: for line in json_data: try: dataText = json.loads(line) except ValueError: continue for a in dataText: print(a["user"]["location"]) the result is: string indices must be integers Update: The below answer is for printing print(dataText["user"][

tweepy stream to sqlite database - syntax error [duplicate]

拥有回忆 提交于 2019-12-02 11:44:33
Possible Duplicate: tweepy stream to sqlite database - invalid synatx I'm getting a syntax error in my code and I can't figure out what's causing it. This is the error the console is returning and nothing is being inputed to the sqlite file. Filtering the public timeline for "@lunchboxhq" RT @LunchboxHQ: @lunchboxhq test1 LunchboxHQ 2012-02-27 17:26:14 Echofon Encountered Exception: near "?": syntax error @LunchboxHQ test 1 LunchboxHQ 2012-02-27 17:26:36 Echofon Encountered Exception: near "?": syntax error @LunchboxHQ test 2 LunchboxHQ 2012-02-27 17:26:51 Echofon Encountered Exception: near "

Tracking keywords in a live stream of tweets

妖精的绣舞 提交于 2019-12-02 10:11:57
I installed and tried out tweepy, I am using the following function right now: from API Reference API.public_timeline() Returns the 20 most recent statuses from non-protected users who have set a custom user icon. The public timeline is cached for 60 seconds so requesting it more often than that is a waste of resources. However, I want to do extract all tweets that match a certain regular expression from the complete live stream. I could put public_timeline() inside a while True loop but that would probably run into problems with rate limiting. Either way, I don't really think it can cover all

Python script receiving a UnicodeEncodeError: 'ascii' codec can't encode character

我与影子孤独终老i 提交于 2019-12-02 09:36:17
I have a simple Python script that pulls posts from reddit and posts them on Twitter. Unfortunately, tonight it began having issues that I'm assuming are because of someone's title on reddit having a formatting issue. The error that I'm reciving is: File "redditbot.py", line 82, in <module> main() File "redditbot.py", line 64, in main tweeter(post_dict, post_ids) File "redditbot.py", line 74, in tweeter print post+" "+post_dict[post]+" #python" UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in position 34: ordinal not in range(128) And here is my script: # encoding=utf8

Parsing JSON fails as strings appear instead of dicts/lists [closed]

不想你离开。 提交于 2019-12-02 09:24:43
with open('twit/example.json', encoding='utf8') as json_data: for line in json_data: try: dataText = json.loads(line) except ValueError: continue for a in dataText: print(a["user"]["location"]) the result is: string indices must be integers Update: The below answer is for printing print(dataText["user"]["location"]) now I want this one: print(a["user"]["location"]) If your json file is in a normal format, use this instead: with open('twit/example.json', encoding='utf8') as json_data: dataText = json.loads(line) for a in dataText: print(dataText["user"]["location"]) The way your code is

Search term intersection and union using Python Tweepy

試著忘記壹切 提交于 2019-12-02 09:12:40
问题 I would like to get the tweets that either contain 'love' and/or '#hate' using Python Tweepy. But using my current code as below, it only returns the first term (i.e. 'love'). I have been trying for days to debug and read the Tweepy/Twitter documentation to no avail. Please advice. import tweepy import time ckey = "" csecret = "" atoken = "" asecret = "" OAUTH_KEYS = {'consumer_key':ckey, 'consumer_secret':csecret, 'access_token_key':atoken, 'access_token_secret':asecret} auth = tweepy

Tweepy Tracking Multiple Terms

我是研究僧i 提交于 2019-12-02 08:12:36
问题 I am doing content analysis on tweets. I'm using tweepy to return tweets that match certain terms and then writing N amount of tweets to a CSv file for analysis. Creating the files and getting data is not an issue, but I would like to reduce data collection time. Currently I am iterating through a list of terms from a file. Once the N is reached (eg 500 tweets), it moves to the next filter term. I would like to input all my terms (less than 400) into a single variable and all the results to

Search term intersection and union using Python Tweepy

南楼画角 提交于 2019-12-02 03:39:58
I would like to get the tweets that either contain 'love' and/or '#hate' using Python Tweepy. But using my current code as below, it only returns the first term (i.e. 'love'). I have been trying for days to debug and read the Tweepy/Twitter documentation to no avail. Please advice. import tweepy import time ckey = "" csecret = "" atoken = "" asecret = "" OAUTH_KEYS = {'consumer_key':ckey, 'consumer_secret':csecret, 'access_token_key':atoken, 'access_token_secret':asecret} auth = tweepy.OAuthHandler(OAUTH_KEYS['consumer_key'], OAUTH_KEYS['consumer_secret']) api = tweepy.API(auth) for tweet in