Data Collection

How to Search For a Specific Location in Tweepy

Some tricks on the usage of the Tweepy library for Python

Photo by Joshua Sortino on Unsplash

In general, we can extract tweets from a given places, by specifying in the query string one of the following keywords, followed by :

place - the place name or the place ID

place_country - the country code. See here for the country code

point_radius - the circular geographic area within which to search for

bounding_box - the 4 sided geographic area, within which to search for.

For more details, you can read the full Twitter Documentation.

In the following example, I search for all the tweets located in Rome:

place = 'Rome'
tweets_list = tweepy.Cursor(api.search, q="place: " + place,tweet_mode='extended', lang='it').items()

A big thank to Kian Tiari for his helpful comment.

This post is a response to the article How to build a dataset from Twitter using Python tweepy, which is available at the following link:

Top 1000 Medium Writer in May, June and July 2021. I write on Data Science, Python, Tutorials and, occasionally, Web Applications.

Top 1000 Medium Writer in May, June and July 2021. I write on Data Science, Python, Tutorials and, occasionally, Web Applications.