from bs4 import BeautifulSoup from urllib.request import urlopen import requests
## Function for downloading defpage_download(image_name,r): try: withopen('./img/%s' % image_name, 'wb') as f: for chunk in r.iter_content(chunk_size=128): f.write(chunk) except: print("missing")
Num = 0 for link in Book_list: try: Num += 1 url = link.find('img')['src'] r = requests.get(url, stream=True) image_name = str(Num)+'.jpg' page_download(image_name,r) print('Saved %s' % image_name) except: print("Missing")