Created
March 13, 2022 12:17
-
-
Save vladiant/2f66d19d1523584b9424940d2729742f to your computer and use it in GitHub Desktop.
imgbox.com gallery downloader
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
import urllib.request | |
import requests | |
from bs4 import BeautifulSoup | |
with open("images.txt", "r") as fp: | |
lines = fp.readlines() | |
for url in lines: | |
r = requests.get(url=url.strip()) | |
print(f"URL: {url.strip()}") | |
soup = BeautifulSoup(r.content, features='html5lib') | |
for img in soup.find_all('img', title=True, src=True): | |
print(f"Saving {img['src']} as {img['title']}") | |
urllib.request.urlretrieve(img['src'], img['title']) | |
print("Done.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment