README
¶

scraper
scraper is a fast, concurrent Go CLI for downloading images from web pages. It uses a priority queue scheduler and a configurable worker pool to fetch assets efficiently, with automatic retry on transient errors.
Features
- Concurrent Downloads: Spawns 20 parallel workers backed by a heap-based priority queue that deprioritizes recently-failed links.
- Recursive Crawling: Optionally follows anchor links within the same domain to discover and download images across an entire site.
- Retry Logic: Failed fetches are re-queued with backoff up to 3 attempts before giving up.
- Dry Run Mode: Preview all discovered URLs without writing any files to disk.
- Original Images: Requests images without advertising WebP/AVIF, so image CDNs serve the original file rather than a lossy transcode.
- Sensible Filenames: Files keep their URL basename; generic names like
original.jpguse the parent path segment (the photo ID) instead. The extension follows the servedContent-Type, and a UUID is appended only when a file with that name already exists, so nothing is ever overwritten.
Quick Start
# Download all images from a page
scraper --output ./images https://example.com
# Recursively crawl the entire site
scraper --recurse --output ./images https://example.com
# Dry run — print discovered links without downloading
scraper --dryrun https://example.com
Options
| Flag | Description | Default |
|---|---|---|
--output |
Output directory for downloaded files (required) | "" |
--recurse |
Follow anchor links within the same domain | false |
--dryrun |
Print links without downloading | false |
--input-file |
Read the first URL's content from a local file instead of fetching it (for pages behind a login or captcha) | "" |
Logged-in Galleries
Some galleries (e.g. the photo gallery of a Rover stay) only appear when you are logged in, and they are rendered by JavaScript. They often also virtualize the list, so photos you have scrolled past are removed from the page. Saving the page from the browser doesn't capture them. The workaround is to collect the image URLs in the browser, write them into a small HTML file, and feed that file to scraper with --input-file.
This only works if the image URLs themselves can be fetched without a login. Check by opening one in a private window.
-
Open the gallery in Chrome while logged in, then open the DevTools console (
⌥⌘J). The first time, Chrome makes you typeallow pastingbefore it accepts a paste. -
Paste the collector, adjusting
MATCHto a substring that identifies the gallery's image URLs:(() => { const MATCH = '/cf-image-cdn/remote/images/messages/'; // Rover stay photos window.galleryUrls = new Set(); const add = u => { if (u && u.includes(MATCH)) { const x = new URL(u); x.search = ''; // drop resize params -> original image galleryUrls.add(x.href); } }; performance.getEntriesByType('resource').forEach(e => add(e.name)); new PerformanceObserver(l => l.getEntries().forEach(e => add(e.name))) .observe({ type: 'resource', buffered: true }); let last = 0; window.galleryTimer = setInterval(() => { document.querySelectorAll('img').forEach(i => add(i.currentSrc || i.src)); if (galleryUrls.size !== last) { last = galleryUrls.size; console.log(last + ' images so far'); } }, 300); })();It records URLs both from the browser's resource timing log and from the
<img>tags currently on the page. That way photos served from the memory cache, which don't create new timing entries, and photos the virtualized list has removed are both caught. -
Scroll slowly through the whole gallery until the count matches the number of photos in the gallery.
-
Export the URLs as an HTML file (it lands in
~/Downloads):(() => { clearInterval(galleryTimer); const html = '<html><body>\n' + [...galleryUrls].map(u => `<img src="${u}">`).join('\n') + '\n</body></html>'; const a = document.createElement('a'); a.href = URL.createObjectURL(new Blob([html], { type: 'text/html' })); a.download = 'gallery.html'; a.click(); console.log(galleryUrls.size + ' images saved'); })(); -
Download everything. The URL argument is required but its content comes from the file:
scraper --dryrun --input-file ~/Downloads/gallery.html https://www.rover.com/account/stays/<id>/ scraper --input-file ~/Downloads/gallery.html --output ./photos https://www.rover.com/account/stays/<id>/
Use a fresh, empty --output directory for each run. Existing files are never overwritten: a second run into the same directory saves each image again under <name>-<uuid>.<ext>, leaving you with duplicates.
Installation
go install github.com/uwedeportivo/scraper@latest
Build
With Bazel (from source)
bazel build //:scraper
bazel run //:scraper -- --dryrun https://example.com
With Go
go build -o scraper .
./scraper --output ./images https://example.com
Update Bazel deps after changing go.mod
bazel run //:gazelle
Documentation
¶
There is no documentation for this package.