Getting trending hashtags for certain countries - twitter

I am trying to get the trending hashtags and keywords for certain countries. Now I know that there is Twitter API and I've been using Twitter API V2, where there is no API call that will allow us to extract the trending hashtags for specific countries.
I then used Twitter V1 to extract the list of trending hashtags, but I realised that some countries are missing (For example, Iraq).
But what was intriguing was the fact, if you go to the settings section and choose to show the trends according to a location of your choice and you choose Iraq, you will get a list of the most trending hashtags for Iraq.
I tried to automate this using Selenium. It worked locally, but I faced issues when I tried to deploy it on a server. I used XFVB to run chrome and selenium on my Linux server but for some reason after a while, the automation process stops as I'm taken suddenly back into the login page.
Does any know of any alternative way, where I can extract the trending hashtags for countries such as Tunisia, Iraq or Algeria. Countries that are not part of the countries listed as part of the Twitter V1, but are available if you manually pick the location you want the trends to be showcased. (https://twitter.com/settings/trends, this URL in the explore locations option, you can pick your country. Here you can find Iraq among other countries)

Related

Historical YouTube Trending videos by date and country

I am looking for a way to get top-50 most popular videos from Explore Tab for a specific date or a period of time for a specific country. Can't find a way how to do it in YouTube API Documentation. Is there a way? If not, maybe you know some workarounds for getting a historical data?
For example, I could build a web scraper that would collect trending videos from Wayback Machine but it shows trending videos in the U.S. only.
Also, found YouTube Charts website, but it shows only music.
As far as I know, there is no such public endpoint or public resource to get these results - besides Wayback Machine and the public/official YouTube channels you can find on their website.
However, since you mentioned using Wayback Machine, you could follow these steps:
Enter to Wayback Machine and search for results about the Pouplar on YouTube channel - see example of extract from Jun 15, 20211.
Retrieve the videos shown in the search results from step 1.
That being said, I recommend you to start creating a database for record trending videos everyday - not sure how you can do this by region, though (this is due there are trending videos by "main countries" like UK, India, some parts of Asia, France, but, as I searched, trending applies for ALL countries) - if I'm wrong in this, please, let me know.
Another possible way to get close results to your expectations could be:
Enter to Popular on YouTube channel and check the Popular now playlist.2
Retrieve those results and organize the results - with this, I mean: check the publication date, check the channel's country/location, etc. It's up to you to check how to organize the available data.
1 Please check that probably there is no data/snapshot on a given day you require - using Wayback Machine -.
2 According to the updated date, this playlist is updated everyday, so, you have to make the same procedure mentioned above (create a database that store results everyday, etc.).
Not sure if with an VPN you can set the VPN and try to get the "Popular now" videos from the selected VPN country, might worth give it a try.
Try also contact with YouTube - probably you might get some sort of answer, ask them if they can provide information about trending videos from a specific region - in a specific time.

Is there any methods to get the like list of a tweet?

I want to get the complete like list of a specific tweet, but the Twitter API only provided an API that can retrieve the 100 most recent users who liked the specific tweet. I also looked for Twitter crawlers on Github, but they all worked in a user-oriented manner, ie they can only get a list of liked tweets of a user, not a list of liking users of a specific tweet.
I also tried to crawl the list using selenium, but maybe due to my limited skill, it didn't work well. I don't want to spend a lot of time studying selenium and front-end knowledge just to accomplish a simple thing, so are there any open source codes or twitter APIs that can do this?
Yes. This has just been announced in the Twitter API v2.
Previously, you were limited to the 100 most recent Likes or Retweets with these endpoints. We heard your feedback that this was too limiting and have updated these endpoints to now return all results. To retrieve a complete list of Likes and Retweets, you can now use pagination.
Use the v2 Likes lookup endpoint: GET /2/tweets/:id/liking_users

How to filter tweets by location using Twitter API

Does Twitter still allow searching tweets by location (for tweets that have been geo-tagged)? The articles I've read describe an advanced search that no longer works the same way, so I'm thinking Twitter discontinued this capability sometime within the past year or two.
I want to filter tweets by geo location programmatically using their API. I can't find documentation on how to do this anywhere. There is one search query operator called point_radius that is exactly what I want, but it appears only accessible to "Academic Research only" projects while I've only been granted "Standard product track".

How can I retrieve the N most popular tweets for a country using the Twitter API?

TL;DR: I want to be able to retrieve the N most popular tweets for any arbitrary country within the last X hours (up to 24 hours)
More detail
I want to show the details of the most popular tweets by geographic region (country) over the past few hours (adjustable up to 24 hours). How can I use the Twitter REST API to achieve this (v1.1 or v2)?
There are endpoints for querying tweets and filtering by popularity, but they require a search string (e.g. "NASA") and return the most popular tweets matching that search string. I am not interested in the contents of the tweets, I just want to know what is most popular.
I plan on using this functionality to show a world map (using Leaflet) to summarise the most popular tweets by country for the past day.
I am using Twit in NodeJS but not looking for answers specific to Node, rather how to leverage the capabilities of the API.
I am not aware of a way that this can be done directly through the API itself (V1 or V2). I also do not think that this is going to be a trivial task at all.
What I would suggest is using the search endpoint...
V1: Reference
V2: Reference Note that to use geolocation search parameters (see below) you'll need academic access.
... in conjunction with one of the geolocation search parameters. For example, you could pull some subset of tweets from within a country (you will not be able to download all tweets within a single country on any given day, not to mention all countries). After you get this data, you'll need to do some of your own data processing based on how you want to define "popular" (e.g. retweets, likes, etc.) and then go from there.
As I said earlier, this seems like a very large project and not something that can be solved simply with the Twitter API.

Using the Twitter node in Node-RED

I have been using the "Twitter" node in Node-RED app and I have tried various alternatives.
If I use the node on the public stream for tweets containing the configured search term all I get is "rate limit hit" irrespective of the search term. I have tried #hybridcloud, #IoT and #cognitive
If I use the node to search all the tweets from accounts that I follow it works perfectly.
If I use the node to search all tweets by specified users it does not appear to work at all. I can see no errors and even though I can tweets on Twitter itself nothing appears in app. I have used common twitter users like #IBMWatson, #NodeRED #the_jsf and #IBMBluemix Now working
I have used the same basic flow, see diagram, for each of the 3 variants.
Any assistance gratefully received.

Resources