[PYTHON] Program to get favorite images on Twitter

Background of making this program

・ Because I wanted to keep the image of the tweet I liked. ・ To look back at tweets that you liked in the past.

The purpose of writing this program was because I wanted to eliminate the inconvenience I felt.

When I tried to look at the tweets I liked in the past, I felt that it was very difficult to use because the current Twitter specifications had no choice but to scroll down the screen to find it.

I wondered if I could solve this problem, and found out that the company that manages Twitter offers api. I thought I could make it myself this way, so I made this program in python language.

Commitment to the code

There are two commitments to this program.

One is that we aimed for highly readable code. This is so that the person reading the code and the future self can understand it in as little time as possible.

I used a function to make the main processing part refreshing, and devised a function name so that it is easy to understand what kind of processing is being performed inside.

The second is that it is easy to customize.

By changing the value of the variable at the beginning of the code, you can change the number of users' accounts and images to get.

Also, you can set the maximum number of images that can be saved in the image save folder.

Technology used

Python …… I wrote the skeleton code in this language. Pandas …… A library that allows you to handle data frames within python. request …… Used to check if data exists at the end of the url path from python. json …… A library that allows you to handle json format data in python. csv …… Used to enable output from python in csv file format. os …… I used python so that the directory path to the save folder can be used. re …… Used to perform regular expression operations in python. This removes the characters and symbols that are not available in the windows environment. Twitter API …… The official API provided by Twitter. Use this to get a tweet. Tweepy …… A library that makes it easy to use the Twitter API in python. Jupyter Notebook …… Used as the main editor. Trial and error of the code was done in this. VScode …… Editor. Finally, I used it for a clean copy of the code and a test execution of the program. Sourcetree …… Used for version control and code backup with git.

Source code

Source code ... https://gist.github.com/takutakumi/999a8e76fe725f4e38002bf39c5657d7

Recommended Posts

Program to get favorite images on Twitter
Get images from specific users on Twitter
Get only image tweets on twitter
I made a program to collect images in tweets that I liked on twitter with Python
Get delay information on Twitter and tweet
Get images by keyword search from Twitter
Get Twitter bookmarks on CentOS using Selenium
Get Twitter userData
Save the search results on Twitter to CSV.
Think about how to program Python on the iPad
Steps to measure coverage and get badges on codecov.io
I get "too early to create image" on tkinter
Character count on Twitter
Easy Twitter Posting Program
Program to weaken Japanese
Memo to get the value on the html-javascript side with jupyter
I get [Error 2055] when trying to connect to MySQL on Heroku
How to get Instruction Pointer (= program counter) in Linux kernel
Save images on the web to Drive with Python (Colab)