10/19/2023 0 Comments Python tweet archiverIf you want to have different criteria for different languages (eg. The query above shows all Tweets from me, that were published on, contain an image or video, got at least 5 faves and aren’t in German. from:luca since: until: filter:media min_faves:5 -lang:de Longer queries are only possible with the Premium API. You can combine all of the things above until you hit the 128 character limit of web search. Especially useful in combination with from:account or filter:follows. It allows you to search through retweets as well. Tweets that do not contain sensitive material. Tweets that contain a URL to a news source. Tweets that contain a video, that was directly uploaded to Twitter. Tweets that got a minimum amount of replies. Tweets that were retweeted less than that many times Tweets that were at least retweeted that many times. Tweets that have fewer faves than specified. Tweets with at least that amount of faves. Tweets that were posted in specific locations and optionally within a certain range. “und” for Tweets where Twitter was unable to determine a language. Language is detected by Twitter on a Tweet basis. Replies and mentions for a specific user. Tweets that are not marked as sensitive media. Be aware that some of them become less reliable when they are used in combination with older timeframes (older than 10 or 30 days). These advanced operators will help you narrow the search down. There are billions of Tweets and you are looking for a very specific one. "fresh van root"įinally, you sometimes want to exclude Tweets that contain a certain term. fresh OR van OR rootįor an exact match, you add quotes. If you want to find Tweets with at least one of them instead of all of them, you need to explicitly state it with an OR between each term. It doesn’t matter in which order the terms appear in the Tweet (or the name of the user who tweeted it). They show results that contain all of the terms in the query. Per default, Twitter interprets a space as an AND-operator. While most people are familiar with basic search queries, only a few know all advanced operators and filters as some aren’t documented (yet) by Twitter.ĭo you know how to find all Tweets that quote a Tweet by a specific user? Or how to find Tweets that are either in German and got 100 Retweets or in English and got 1000 Retweets but less than 10 replies? Basic Search Queries You can search the full Twitter Archive through the Twitter web search. Then run the following commands to make the service run daily (this can be changed by editing the tweetarchiver.Since Twitter bought summize in 2008 the best way to search Twitter is Twitter Search. Edit the rvice file and change to the directory where your script is installed. They are user-ran, so to install them, place them in the directory where your systemd user service files are located (probably ~/.config/systemd/user/. I have a user service and a timer that updates the database daily. For instance, I use a Linux distro with systemd. This script is best used when integrated with other programs. -g : get a user's ID based on their username.The script can be run in any of the following modes, and uses GNU style - flags This can be changed by setting the dbName variable. The first time you run this script, it will create an empty, local, SQLite database called tweets.db. Open up the script.py file, find the following variable, and change the user ID. The script returns the given user's display name, username, and user ID. This script provides a handy way of taking a username and returning this information. You will also need to find the user ID of the twitter account whose tweets you want to download and archive. You will need to generate a bearer token, which is used to access publicly available, read-only information on Twitter (such as a users tweets) The token file should contain the bearer token string and nothing else. Visit the Twitter Developer Portal and sign up for a developer account. You will need to create a token file with a bearer token from Twitter. InstallationĪs this script currently only requires tweepy as a dependency. ![]() ![]() This functionality is not directly coded within the script, but I show how I did it at the end of this document. The original purpose of this script was similar to something like the "fortune" program, and my personal usage of it is printing out a random tweet from a specific Twitter user to the terminal every time I open a new one. This database can be updated, and this script also provides functionality to print a random Tweet from the database. This small, simple Python script builds a database of a single user's Tweets locally.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |