noofitem = 1000
tweets = tweepy.Cursor(api.search,q=['#iphone11, -filter:retweets'],since='2019-11-14',lang='en',tweet_mode='extended',retweeted=False).items(noofitem)
i = [tweet.full_text for tweet in tweets] #Tweet text
I am trying to get about 1000 tweets using tweepy. But the max tweets I get are around 600. Changing the date does not work. Any modification or other workarounds will be helpful. Thanks.
Please note that Twitter’s search service and, by extension, the
Search API is not meant to be an exhaustive source of Tweets. Not all
Tweets will be indexed or made available via the search interface.
Please refer to this link for more information: http://docs.tweepy.org/en/latest/api.html#help-methods
Probably you will need to set up a Stream to get the amount of data you need.
Related
Currently I am working on a project with tweepy to collect new tweets from users very quickly. So far, I have found that the fastest method to collect the newest tweet of a user is like so:
tweets = api.user_timeline(screen_name='user',count=1, include_rts = True,tweet_mode = 'extended')
status = tweets[0]
I was wondering if there is anyway to get the most recent tweets of multiple users in one request? I tried using a streamer, but that ended up having about a 10 second delay between when a tweet was posted and when it popped up, which is way too slow for my application. Please let me know if you have any other ideas on how to fetch tweets quickly.
Thanks
I haven't used tweepy to search the posts by user, but I have used it to extract information on multiple hashtags before.
When I tried with multiple hashtags the code looked like this:
query = "(#nike OR #puma OR #adidas)"
rule = gen_rule_payload(query, results_per_call=100, from_date="2020-11-30", to_date="2020-12-02")
So I would try for you query:
users = "(User1 OR User2 OR User3)"
tweets = api.user_timeline(screen_name=users,count=1, include_rts = True,tweet_mode = 'extended')
status = tweets[0]
I'm not sure if that will work, but fingers crossed! The good thing about working with Twitter is that you can copy paste your search strings directly into the search box on a normal twitter webpage and see if your syntax is correct.
Im currently getting all the tweets for a hashtag from a particular account.
By using this I can get hashtags' tweets :
tweepy.Cursor(api.search, q='#marketing', rpp=100).items(10)
By using this I can get tweets of a parituclar Id:
tweepy.Cursor(api.user_timeline, id="someid")
I need to combine these two to get all the tweets for a particular hashtag from an account.
I've tried multiple approaches to combine the above two api calls.
Just use the search API with the parameter q='#marketing from:user' to get tweets from #user containing #marketing.
You can directly use:
tweepy.Cursor(api.search, q="from:screen_name #hashtag")
Example:
tweepy.Cursor(api.search, q="from:someid #marketing")
This issue was raised in the tweepy github repo.
They should have added it in the documentation.
Suppose that a twitter user has sent a tweet which has a specific tweet id. What is the best way to get n tweets from same user exactly before that specific tweet id using tweepy?
Any help will be appreciated.
Read the official Twitter documentation :
https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets.html
And use the parameter q with from:#user and count=10 where 10 is your "n" andmax_id=id where "id" is your tweet id.
And read the officiel tweepy documentation for the seach API.
We can fix bugs for you but won't code for you.
# Initiate the connection to Twitter
twitter = Twitter(auth=oauth)
# Search for latest tweets about "pakistan"
results = twitter.search.tweets(q='pakistan',until=2008 - 08 - 19, )
print results
I am trying to retrieve tweets that are earlier than this date by one week. It does not return anything. However, I have searched manually on twitter and found that tweets exist.
When you use the Twitter API to download tweets you will have access to tweets back to roughly one week old. This is despite the fact that you can see tweets older than one week on Twitter's website. This is a built-in limitation of the API.
To have access to a bigger time span you can do the following ways:
download everyday data and add up gradually.
you can search on the web to find a dataset
The best way is to ask Twitter to give you the data for a specific time span while you have an API developer account. You have asked for a quote using this address:
https://www.trackmyhashtag.com/twitter-dataset#request-data-form
I am trying to fetch all tweets using tweepy. I cannot find a document to show how to fetch all tweets rather than filter data using some keywords.
I tried "stream.filter()" without parameters, but it still does not work.
Could anyone give some help?
Thanks.