This repository has been archived by the owner on Mar 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Basic usage
Francesco Poldi edited this page Dec 10, 2019
·
3 revisions
Command | Usage |
---|---|
-u , --username
|
User's Tweets you want to scrape. |
-s , --search
|
Search for Tweets containing this word or phrase. |
-g , --geo
|
Search for geocoded Tweets. |
--near |
Near a specified city. |
--location |
Show user's location (Experimental). |
-l , --lang
|
Search for Tweets in a specific language (See language codes). |
-o , --output
|
Save output to a file. |
-es , --elasticsearch
|
Index to Elasticsearch. |
--year |
Filter Tweets before specified year. |
--since |
Filter Tweets sent since date (Example: 2017-12-27). |
--until |
Filter Tweets sent until date (Example: 2017-12-27). |
--email |
Filter Tweets that might have email addresses. |
--phone |
Filter Tweets that might have phone numbers. |
--verified |
Display Tweets only from verified users (Use with -s). |
--csv |
Write as .csv file. |
--json |
Write as .json file. |
--hashtags |
Output hashtags in seperate column. |
--userid |
Twitter user id. |
--limit |
Number of Tweets to pull (Increments of 20). |
--count |
Display number of Tweets scraped at the end of session. |
--stats |
Show number of replies, retweets, and likes. |
-db , --database
|
Store Tweets in a sqlite3 database. |
--to |
Search Tweets to a user. |
--all |
Search all Tweets associated with a user. |
--followers |
Scrape a person's followers. |
--following |
Scrape a person's follows. |
--favorites |
Scrape Tweets a user has liked. |
--proxy-type |
Socks5, HTTP, etc. |
--proxy-host |
Proxy hostname or IP. |
--proxy-port |
The port of the proxy server. |
--essid |
Elasticsearch Session ID, use this to differentiate scraping sessions. |
--userlist |
Userlist from list or file. |
--retweets |
Include user's Retweets (Warning: limited). |
--format |
Custom output format (See wiki for details). |
--user-full |
Collect all user information (Use with followers or following only). |
--profile-full |
Slow, but effective method of collecting a user's Tweets and RT. |
--store-pandas |
Save Tweets in a DataFrame (Pandas) file. |
--pandas-type |
Specify HDF5 or Pickle (HDF5 as default). |
-it , --index-tweets
|
Custom Elasticsearch Index name for Tweets. |
-if , --index-follow
|
Custom Elasticsearch Index name for Follows. |
-iu , --index-users
|
Custom Elasticsearch Index name for Users. |
-dt , --doc-type
|
Custom Elasticsearch document type. |
--debug |
Store information in debug logs. |
--resume |
Resume from Tweet ID. |
--videos |
Display only Tweets with videos. |
--images |
Display only Tweets with images. |
--media |
Display Tweets with only images or videos. |
--replies |
Display replies to a subject. |
-pc , --pandas-clean
|
Automatically clean Pandas dataframe at every scrape. |
--get-replies |
All replies to the tweet. |
-pt , --popular-tweets
|
Scrape popular tweets instead of recent ones. |
-sc , --skip-certs
|
Skip certs verification, useful for SSC. |
-ho , --hide-output
|
Hide output, no tweets will be displayed. |
-nr , --native-retweets
|
Filter the results for retweets only (a few tweets will be returned!). |
--min-likes |
Filter the tweets by minimum number of likes. |
--min-retweets |
Filter the tweets by minimum number of retweets. |
--min-replies |
Filter the tweets by minimum number of replies. |
--links |
Include or exclude tweets containing one o more links. If not specified you will get both tweets that might contain links or not. |
--source |
Filter the tweets for specific source client. |
--members-list |
Filter the tweets sent by users in a given list. |
-fr ,--filter-retweets
|
Exclude retweets from the results. |
If you would like to use Tor proxy, just type --proxy-host tor
instead of --proxy-host localhost --proxy-type socks5 --proxy-port 9050
.
--userlist
arg will overwrite --username
arg.
A few simple examples to help you understand the basics:
-
twint -u username
- Scrape all the Tweets from user's timeline. -
twint -u username -s pineapple
- Scrape all Tweets from the user's timeline containing pineapple. -
twint -s pineapple
- Collect every Tweet containing pineapple from everyone's Tweets. -
twint -u username --year 2014
- Collect Tweets that were tweeted before 2014. -
twint -u username --since 2015-12-20
- Collect Tweets that were tweeted since 2015-12-20. -
twint -u username -o file.txt
- Scrape Tweets and save to file.txt. -
twint -u username -o file.csv --csv
- Scrape Tweets and save as a csv file. -
twint -g="48.880048,2.385939,1km" -o file.csv --csv
- Scrape Tweets from a radius of 1km around a place in Paris and export them to a csv file. -
twint -u username -es localhost:9200
- Output Tweets to Elasticsearch -
twint -u username -o file.json --json
- Scrape Tweets and save as a json file. -
twint -u username --database tweets.db
- Save Tweets to a SQLite database. -
twint -u username --followers
- Scrape a Twitter user's followers. -
twint -u username --following
- Scrape who a Twitter user follows. -
twint -u username --favorites
- Collect all the Tweets a user has favorited.