Skip to content

Instantly share code, notes, and snippets.

@Parassharmaa
Last active August 5, 2021 23:10
Show Gist options
  • Select an option

  • Save Parassharmaa/e6a5527bb947b613696d6a949745f76d to your computer and use it in GitHub Desktop.

Select an option

Save Parassharmaa/e6a5527bb947b613696d6a949745f76d to your computer and use it in GitHub Desktop.
Python script to download image from a tweet thread.
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