I need to scrape the exact number of tweets that are generated under certain Twitter accounts on a daily basis. As well as the number of followers.
As far as I know Twitter's streaming API is not complete.
Does anyone know a suitable source - not necessarily from Twitter. I am already scraping from Topsy but I could not figure out yet how to limit the displayed tweets to only a single account. I do not even need the content but only the number of generated tweets and the number of followers.
Thank you!!!
There are several python modules that can be used.
Here is how you could go about getting a list of followers with Twython
(from: How to get twitter followers using Twython?)
from twython import Twython
twitter = Twython()
followers = twitter.get_followers_ids(screen_name = "ryanmcgrath")
for follower_id in followers:
print "User with ID %d is following ryanmcgrath" % follower_id
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.
I am using python package GetOldTweets3 to extract all tweets from a specific user between a specific timeframe. However, I only want the 'original' tweets, and no public replies or retweets the user makes.
Is there any possibility to do this with GetOldTweets3 or any way to expand the package?
import GetOldTweets3 as got
tweetCriteria =
got.manager.TweetCriteria().setUsername(username).setSince(startdate).setUntil(enddate)
tweets = got.manager.TweetManager.getTweets(tweetCriteria)
I've been using GetOldTweets3 recently and I don't think that you'll get user retweets from the result. For the replies, you can just get the reply for each record by adding tweet.to to your result and choose the record that has null for that.
I am using tweepy with python (flask) for a small project. I want to fetch users against a query from twitter. Currently I am using cursor object and it returns me tweets. But I want to fetch users instead of tweets.
I think what I am getting right now via cursor is the top results so I want the results in People tab instead of Top tab.
Any idea how should I do that?
Screenshot is attached for what I want!
https://i.stack.imgur.com/0zGUm.png
I found this in tweepy documentation.
After basic twitter auth:
twitterAuth = twitterClient()
api = twitterAuth.get_twitter_client_api()
api.search_users(q, 20, 1)
Here q is your search term, 20 is the number of results per page (max 20 allowed) and 1 indicates the page number from where you want to collect the users. For example if you want to fetch users from 1st page it will be 1 else any other page number.
Hope this helps everyone!
# 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'm trying to collect tweets using certain hashtags using the twitter api and the tweepy module. I know how to get the 15 most recent tweets using a given hashtag using the code below:
import tweepy
auth = tweepy.OAuthHandler(consumer_key=con_key, consumer_secret=con_secret)
auth.set_access_token(acc_token, acc_secret)
#Connect to the Twitter API using the authentication
api = tweepy.API(auth)
tweet_list = api.search(q = '#23squadgoals')
However I was wondering what parameters I use to specify the number of the tweets to return. Also is there a parameter I can use to specify the timing? Like what I want to collect tweets that were tweeted a week ago?
ANy help would be appreciated!
Thanks,
Ben