Right-click, "Save image as" does not scale past a handful of pictures. Here is a short Python script that downloads every image from a page, plus the traps that make naive scripts miss images or get you blocked.
The script
Install: pip install requests beautifulsoup4 . Run: python grab_images.py https://books.toscrape.com/ images
#!/usr/bin/env python3 """ Download every image from a web page. pip install requests beautifulsoup4 """ import hashlib , os , re , sys , time from urllib.parse import urljoin , urlparse from urllib import robotparser import requests from bs4 import BeautifulSoup
UA = " image-grabber-tutorial/1.0 (+contact: [email protected]) " CSS_URL = re . compile ( r " url\(\s*[ ' \"]?([^ ' \")]+)[ ' \"]?\s*\) " ) LAZY_ATTRS = ( " src " , " data-src " , " data-lazy-src " , " data-original " , " data-lazy " )
def best_from_srcset ( srcset ): """ Pick the largest candidate from ' a.jpg 480w, b.jpg 1080w ' . """ best , best_w = None , - 1 for part in srcset . split ( " , " ): bits = part .…