Last active
August 5, 2021 23:10
-
-
Save Parassharmaa/e6a5527bb947b613696d6a949745f76d to your computer and use it in GitHub Desktop.
Python script to download image from a tweet thread.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from bs4 import BeautifulSoup | |
| import requests | |
| import urllib.request | |
| data = requests.get("https://twitter.com/AmeyShrivastav1/status/857315283253559296").text | |
| soup = BeautifulSoup(data, "html.parser") | |
| #array of tags | |
| img_data = soup.find_all("div", {"class": "AdaptiveMedia-photoContainer"}) | |
| for i in img_data: | |
| #saving images | |
| i = i.find("img")['src'] | |
| urllib.request.urlretrieve(i, i.replace("https://pbs.twimg.com/media/", "")) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment