Often times, after seeing a tweet, I go to https://poet.so to take a screenshot of it. However, this was kinda time consuming and stuff like that, but poet.so doesn't even have an API, so I create a selenium script that (very quickly) uses poet.so to take screenshots of a tweet.
To use the bot, simply reply to any tweet with @poet_this
The project is shockingly simple, but super useful. It hardly took 20 minutes for me to make it (because I already had some experiences with the twitter API - auto twitter banner changer )
in fact, it's so simple that this is all I needed to write (with a little bit of reverse engineering of the website and some keyboard tricks)
def get_poem(self, link, savepath="tweet.png"):
input_box = self.driver.find_element(by= "tag name", value="input")
input_box.send_keys(link + u'\ue007')
element = self.driver.find_element("xpath","//*[@data-export-hide]")
# Waiting for the image to load
time.sleep(5)
element.screenshot(savepath)
Anyways, I hope you like my little project. If you have any suggestions or issues, feel free to post them on github.
The repository is public here:
Please β this!
Dhravya / beautify-this-bot
A twitter bot that simply replies with a beautiful screenshot of the tweet, powered by beautify.dhravya.dev
Installation
git clone https://github.com/dhravya/beautify-this-bot.git
cd beautify-this-bot
pip install -r requirements.txt
Usage
python src/main.py
License
This project is licensed under the MIT license
Show your support
Leave a β if you like this project
Readme made with π using README Generator by Dhravya Shah
I'm considering options to host the bot too, but hosting anything using selenium is quite the pain so i'll try my best. For now it's online on my own computer
Top comments (16)
Is the bot still live??? I tried to take a screenshot with it but nothing happened!
It is still alive!!! Can you please send a link of the tweet where it didn't work?
It worked, I didn't see it early
You are super cool π«ππ½
This looks pretty neat. I'll try it once my application for Twitter API is accepted.
I'll definitely be checking this out, super cool π
Boy! You are flying π!!! Keep up!
I loved the banner changer with followers! I was looking for something like that π
Thanks! Glad I could help β¨
Looks great, I really like this glassmorphism design! π
Really nicely done
Fancy!
This is super cool.
Another cool app, nice work.