A Python package for the simple downloading of tweets with geographical information
Project description
GTdownloader
GTdownloader is a geographical tweets downloading tool that leverages the Twitter API
and searchtweets-v2 to retrieve tweets with geographical information and store them in easy access
formats like .csv and .shp.
Installation
Use the package manager pip to install gtdownloader.
pip install gtdownloader
Twitter keys
To set up your twitter keys file you need to have a developer account with access to the full-archive
search. If you plan to use this as part of academic research, you can apply for researcher
access to the API at
Twitter Academic Research access.
After loging into your developer account, copy the consumer key, the consumer secret and the bearer token into a .yaml
file in the following way:
search_tweets_v2:
endpoint: https://api.twitter.com/2/tweets/search/all
consumer_key: YOUR_CONSUMER_KEY
consumer_secret: YOUR_CONSUMER_SECRET
bearer_token: YOUR_BEARER_TOKEN
Get started
from gtdownloader import TweetDownloader
# create downloader using Twitter API credentials
gtd = TweetDownloader(credentials='twitter_keys.yaml')
# get a batch of 400 tweets in english containing the word "tornado"
# between the dates 07/23/2022 and 07/29/2022
gtd.get_tweets('tornado',
lang='en',
max_tweets=400,
start_time='07/23/2022',
end_time='07/29/2022'
)
# accessing tweets data frame
print(gtd.tweets_df.head())
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for gtdownloader-0.1.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17bd2471bc589e7a35f1dbf5663db28545244dedaae31142671e48de1087e5ec |
|
MD5 | b2c04f34a7740a1419fc6ef189f11961 |
|
BLAKE2b-256 | ee3367768512d698e3189250bbe9206d05ebc2f664bc6c43495a48b33295292b |