Created
April 25, 2020 13:04
-
-
Save bauripalash/33aa9c32eed5d0ca58847d9c17bff340 to your computer and use it in GitHub Desktop.
This file contains 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 as bs | |
import sys | |
import requests | |
def main(): | |
if len(sys.argv) == 2: | |
URL = sys.argv[1] | |
soup = bs(requests.get(URL).content , "html.parser") | |
for image in soup.find_all("img"): | |
if image["src"]: | |
img = image["src"] if image["src"].startswith("http") else URL + image["src"] | |
r = requests.get(img, stream = True) | |
with open(img.split("/")[-1] , "wb") as f: | |
for ch in r: | |
f.write(ch) | |
else: | |
print("Usage: python imgdown.py <URL>") | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment