I was wondering if there was a way to retrieve tweets in a specific trend? For example, a trend right now is #AirAsia and therefore, I would like to get, for example, 50 tweets from that trend. I tried looking at tweepy but couldn't find anything except for trends in a certain location.
EDIT
I would like to clarify that I am not looking for a specific hashtag but a trend. For example, as mentioned in the comments, "Greece" is a trend but it is not a hashtag. Therefore, a trend is not necessarily a hashtag and vice versa, a hashtag is not necessarily a trend.
Use Twitter Search:
https://twitter.com/search-home
Or:
Google "twitter hashtag airAsia" or go to the address https://twitter.com/hashtag/airasia
You can retrieve as many tweets as you want in any given trend.
Note that method #1 of using Twitter's search engine allows you to search any keyword or trend, which isn't necessarily a hashtag.
Similar to the Twitter Search function, the following Search API can be used to find tweets 'containing an exact phrase': Link to Search API Documentation
Related
Im trying to get all of a user's tweets for a 2 month time period. In search I see results but this code returns an empty array. Why?
results = api.GetSearch(raw_query="q=&from=yikyakapp&since=2014-09-24&until=2014-11-24")
print(results)
This is because Twitter search API has a limit of 7 days. Check the API documentation
The Twitter Search API searches against a sampling of recent Tweets published in the past 7 days.
There is a detailed explanation here https://dev.twitter.com/rest/reference/get/search/tweets
Keep in mind that the search index has a 7-day limit. In other words,
no tweets will be found for a date older than one week.
In summary, you can't use Twitter API to search for tweets beyond 7 days. Of course, in the website they can show you whatever they want. They hold all the data.
So basically what I want to do is use the streaming API to search for certain emoji but also only pull tweets from within the United STates. Does anyone know how I would go about this? I am using python. Currently I am just pulling all tweets with the emoji and manually going through them to see if the tweets are from the US.
This is my current code:
twitterStream.filter(track=["Ossoff"],languages=['en'])
What can I add to this so it only searches for the track term in a bounded location? Or is this even possible?
Not possible. The relevant API doc is here. Quoting the doc:
Bounding boxes do not act as filters for other filter parameters. For example track=twitter&locations=-122.75,36.8,-121.75,37.8 would match any Tweets containing the term Twitter (even non-geo Tweets) OR coming from the San Francisco area.
I am writing a script in Python, that uses tweepy to search for tweets with a given keyword. Here is the snippet:
for tweet in tweepy.Cursor(api.search, q=keyword, lang="en").items(10):
print tweet.id
I have everything authenticated properly and the code works most of the time. However, when I try to search for some keywords (examples below) it doesn't return anything.
The keywords that cause trouble are "digitalkidz" (a tech conference) and "newtrendbg" (a Bulgarian company). If you do a quick search on Twitter for either of those you will see that there are results. However, tweepy doesn't find anything. Again, it does work for pretty much any other keyword I use.
Do you have any ideas what might be the problem and how to fix it?
Thank you
I believe you're forgetting an important aspect of the twitter api, it's not exhaustive.
Taken from the api docs
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.
Regardless of whether you're using the streaming or rest api, you're going to have issues with this if you're looking for specific tweets.
Rest API
When looking for historical tweets, you unfortunately won't be able to obtain anything that is older than a week using api.search(). This is also shown in the docs.
Keep in mind that the search index has a 7-day limit. In other words, no tweets will be found for a date older than one week.
There are other ways of getting older tweets, this post details those options.
Streaming API
While it doesn't sound like you're using twitter's streaming API, it should be noted that this only gives a small sample of twitter's current tweet traffic (~1-2%).
Hopefully this is helpful. Let me know if you have any questions.
I would like to be able to call a function, in any language (preferably Python :)), where the parameters I pass in are simply a date, or date range, and I get returned a list of the topics that were trending on Twitter (or any other social media) on these dates.
Is it possible to do this? How can I do this if so?
Thank you very much.
It doesn't seem possible through the official 1.1 twitter API, which only provides currently trending topics, but http://twend.it archives trending topics on twitter. You may be able to scrape them or send an email asking if they have an API.
I have the following questions about tweepy python module
1.I am trying to retrieve all tweets for a specific location. I am able to do this by using tweepy python module (streaming API), but I get only those tweets whose geo locations are enabled, which means I would loose rest of the tweeter’s tweet who have not enabled their geo location. Is there a better way to retrieve all the tweets, given a location?
2.I use Stream.Sample method to retrieve all the tweets, Can someone tell me about the parameters used in sample method? I see count, and async as parameters. Now what should we specify here?
3.What does firehose method in tweepy.Stream do?
Any help is much appreciated
If tweepy doesn't have a feature you need, you can always access Twitter directly with an HTTP request. The full Twitter REST API is described here: https://dev.twitter.com/docs/api
The ones that seem relevant to your interest are:
GET trends/:woeid which looks up tweets by woeid, a Yahoo Identifier for collecting information about a given place/landmark/etc.
GET geo/id/:place_id which only mines geotagged tweets.
There is documentation of all the information available for a GET request but the IP address is not among the available fields: https://dev.twitter.com/docs/api/1/get/search .
Lastly, Twitter has a location search FAQ that may be of interest.