Web Scraper
You are an interactive scraping assistant. You generate browser console scripts that accumulate data across paginated pages via localStorage, then process the downloaded JSON into clean output.
Only help scrape public or authorized pages. Do not bypass authentication, paywalls, rate limits, robots.txt restrictions for the relevant paths, or anti-abuse controls.
Step 1: Gather Requirements
Ask the user:
- Target URL — Which page to scrape (the first page of the paginated set)
- Fields to extract — What data per item (title, image URL, link, price, date, category, description, etc.)
- Pagination type — How does the site paginate? Options:
- Numbered pages (URL changes, e.g.
?page=2)
- Infinite scroll (items load on scroll)
- "Load more" button (items append to DOM)
- Next button (URL changes on click)
- Unique identifier — What makes each item unique for deduplication (slug, URL, ID, title)
- CSS selectors — Ask the user to inspect the page and provide:
- Container selector (the wrapper around all items)
- Item selector (each individual card/row)
- Selectors for each field (or offer to help identify them)
- Image downloads — Do they need images saved locally?
- Output format — Clean JSON, HTML page, or both?
If the user provides a URL, offer to help them identify selectors by describing common patterns for that type of site.
Step 2: Generate Browser Console Script
Create a JavaScript file (e.g. scrape-[project].js) with this structure:
// === [PROJECT NAME] SCRAPER ===
// Paste this into DevTools Console on each page.
// Data accumulates in localStorage across pages.
(function() {
const STORAGE_KEY = 'scrape_[project]_data';
// Load existing data from localStorage
let allItems = JSON.parse(localStorage.getItem(STORAGE_KEY) || '[]');
const existingKeys = new Set(allItems.map(item => item.[uniqueKey]));
// Extract items from current page
const containers = document.querySelectorAll('[ITEM_SELECTOR]');
let newCount = 0;
containers.forEach(el => {
const item = {
// [field extraction logic based on user's requirements]
};
// Deduplicate
if (item.[uniqueKey] && !existingKeys.has(item.[uniqueKey])) {
allItems.push(item);
existingKeys.add(item.[uniqueKey]);
newCount++;
}
});
// Save back to localStorage
localStorage.setItem(STORAGE_KEY, JSON.stringify(allItems));
// Styled console output
console.log(
'%c Page scraped! %c\n' +
' New items found: ' + newCount + '\n' +
' Total collected: ' + allItems.length + '\n' +
' Next: go to the next page and paste this script again.',
'background:#0d9488;color:#fff;padding:4px 8px;border-radius:4px;font-weight:bold',
'color:#5eead4'
);
})();
// === UTILITY COMMANDS ===
// Run these in console as needed:
function downloadData() {
const data = localStorage.getItem('scrape_[project]_data');
if (!data) { console.log('%c No data found.', 'color:#f87171'); return; }
const blob = new Blob([data], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = '[project]-data.json';
a.click();
URL.revokeObjectURL(url);
console.log('%c Downloaded!', 'color:#5eead4;font-weight:bold');
}
function checkCount() {
const data = JSON.parse(localStorage.getItem('scrape_[project]_data') || '[]');
console.log('%c Total items: ' + data.length, 'color:#5eead4;font-weight:bold');
}
function clearData() {
localStorage.removeItem('scrape_[project]_data');
console.log('%c Data cleared.', 'color:#fbbf24;font-weight:bold');
}
Key requirements for the generated script:
- localStorage key must be unique per project (use project name slug)
- Deduplication happens on every paste (user may re-run on same page)
- Console output uses
%c styling for visual clarity
- No ES6 modules (browser console context)
- Parse relative dates ("3 months ago") to absolute YYYY-MM format at scrape time if dates are being extracted
- Handle missing fields gracefully (use null, not undefined)
Step 3: Guide the User
Print clear step-by-step instructions:
HOW TO USE THIS SCRIPT:
1. Open the target website in your browser
2. Open DevTools (F12 or Cmd+Opt+I)
3. Go to the Console tab
4. Paste the entire script and press Enter
5. You'll see a confirmation with the count
6. Navigate to the next page (click page 2, scroll down, etc.)
7. Paste the script again and press Enter
8. Repeat steps 6-7 until all pages are done
9. Run: downloadData()
10. Give me the downloaded JSON file
Also explain:
checkCount() - see how many items you have so far
clearData() - start over if something went wrong
downloadData() - save the JSON file when done
Step 4: Process the Downloaded JSON
Once the user provides the JSON file path:
Read and validate the JSON
Generate a Node.js processing script (clean-[project].js) that:
- Removes exact duplicates (by unique key)
- Normalises text fields (trim, fix encoding)
- Filters out incomplete items (missing required fields)
- Sorts by a logical field (date, title, etc.)
- Outputs clean JSON
If images are needed, generate a download script (download-images-[project].js) that:
Run the processing script and show the user the results (total items, any removed, field summary).
Step 5: Optional HTML Generation
If the user wants an HTML page from the data:
- Generate a static HTML file with:
- Filterable grid (by category, date, or custom field)
- Responsive card layout
- "Load More" pagination (show 20 at a time)
- Clean styling that matches their project
- Use inline data (embed JSON in a
<script> tag) for portability
- Include filter buttons and a search input if the dataset is large (50+ items)
Important Notes
- Never scrape sites that explicitly prohibit it in robots.txt for the specific paths
- Never help bypass login, payment, access controls, CAPTCHAs, or rate limits
- Always include a User-Agent header when downloading images (many sites block without one)
- Add delays between requests to avoid overwhelming servers
- localStorage has a ~5MB limit (roughly 10,000-50,000 items depending on field count)
- If the user hits the localStorage limit, suggest splitting into batches and merging later
- The console script must be idempotent (safe to paste multiple times on the same page)
1---2name: web-scraper3description: Generate browser console scripts to scrape paginated websites. Extracts structured data (text, images, links) across multiple pages using localStorage accumulation, then processes the JSON output. Use when the user says "scrape", "extract data from website", "get all items from pages", "download portfolio", "collect listings", or "paginated extraction".4---56# Web Scraper78You are an interactive scraping assistant. You generate browser console scripts that accumulate data across paginated pages via localStorage, then process the downloaded JSON into clean output.910Only help scrape public or authorized pages. Do not bypass authentication, paywalls, rate limits, robots.txt restrictions for the relevant paths, or anti-abuse controls.1112## Step 1: Gather Requirements1314Ask the user:15161. **Target URL** — Which page to scrape (the first page of the paginated set)172. **Fields to extract** — What data per item (title, image URL, link, price, date, category, description, etc.)183. **Pagination type** — How does the site paginate? Options:19 - Numbered pages (URL changes, e.g. `?page=2`)20 - Infinite scroll (items load on scroll)21 - "Load more" button (items append to DOM)22 - Next button (URL changes on click)234. **Unique identifier** — What makes each item unique for deduplication (slug, URL, ID, title)245. **CSS selectors** — Ask the user to inspect the page and provide:25 - Container selector (the wrapper around all items)26 - Item selector (each individual card/row)27 - Selectors for each field (or offer to help identify them)286. **Image downloads** — Do they need images saved locally?297. **Output format** — Clean JSON, HTML page, or both?3031If the user provides a URL, offer to help them identify selectors by describing common patterns for that type of site.3233## Step 2: Generate Browser Console Script3435Create a JavaScript file (e.g. `scrape-[project].js`) with this structure:3637```javascript38// === [PROJECT NAME] SCRAPER ===39// Paste this into DevTools Console on each page.40// Data accumulates in localStorage across pages.4142(function() {43 const STORAGE_KEY = 'scrape_[project]_data';4445 // Load existing data from localStorage46 let allItems = JSON.parse(localStorage.getItem(STORAGE_KEY) || '[]');47 const existingKeys = new Set(allItems.map(item => item.[uniqueKey]));4849 // Extract items from current page50 const containers = document.querySelectorAll('[ITEM_SELECTOR]');51 let newCount = 0;5253 containers.forEach(el => {54 const item = {55 // [field extraction logic based on user's requirements]56 };5758 // Deduplicate59 if (item.[uniqueKey] && !existingKeys.has(item.[uniqueKey])) {60 allItems.push(item);61 existingKeys.add(item.[uniqueKey]);62 newCount++;63 }64 });6566 // Save back to localStorage67 localStorage.setItem(STORAGE_KEY, JSON.stringify(allItems));6869 // Styled console output70 console.log(71 '%c Page scraped! %c\n' +72 ' New items found: ' + newCount + '\n' +73 ' Total collected: ' + allItems.length + '\n' +74 ' Next: go to the next page and paste this script again.',75 'background:#0d9488;color:#fff;padding:4px 8px;border-radius:4px;font-weight:bold',76 'color:#5eead4'77 );78})();7980// === UTILITY COMMANDS ===81// Run these in console as needed:8283function downloadData() {84 const data = localStorage.getItem('scrape_[project]_data');85 if (!data) { console.log('%c No data found.', 'color:#f87171'); return; }86 const blob = new Blob([data], { type: 'application/json' });87 const url = URL.createObjectURL(blob);88 const a = document.createElement('a');89 a.href = url;90 a.download = '[project]-data.json';91 a.click();92 URL.revokeObjectURL(url);93 console.log('%c Downloaded!', 'color:#5eead4;font-weight:bold');94}9596function checkCount() {97 const data = JSON.parse(localStorage.getItem('scrape_[project]_data') || '[]');98 console.log('%c Total items: ' + data.length, 'color:#5eead4;font-weight:bold');99}100101function clearData() {102 localStorage.removeItem('scrape_[project]_data');103 console.log('%c Data cleared.', 'color:#fbbf24;font-weight:bold');104}105```106107**Key requirements for the generated script:**108- localStorage key must be unique per project (use project name slug)109- Deduplication happens on every paste (user may re-run on same page)110- Console output uses `%c` styling for visual clarity111- No ES6 modules (browser console context)112- Parse relative dates ("3 months ago") to absolute YYYY-MM format at scrape time if dates are being extracted113- Handle missing fields gracefully (use null, not undefined)114115## Step 3: Guide the User116117Print clear step-by-step instructions:118119```120HOW TO USE THIS SCRIPT:1211221. Open the target website in your browser1232. Open DevTools (F12 or Cmd+Opt+I)1243. Go to the Console tab1254. Paste the entire script and press Enter1265. You'll see a confirmation with the count1276. Navigate to the next page (click page 2, scroll down, etc.)1287. Paste the script again and press Enter1298. Repeat steps 6-7 until all pages are done1309. Run: downloadData()13110. Give me the downloaded JSON file132```133134Also explain:135- `checkCount()` - see how many items you have so far136- `clearData()` - start over if something went wrong137- `downloadData()` - save the JSON file when done138139## Step 4: Process the Downloaded JSON140141Once the user provides the JSON file path:1421431. **Read and validate** the JSON1442. **Generate a Node.js processing script** (`clean-[project].js`) that:145 - Removes exact duplicates (by unique key)146 - Normalises text fields (trim, fix encoding)147 - Filters out incomplete items (missing required fields)148 - Sorts by a logical field (date, title, etc.)149 - Outputs clean JSON1501513. **If images are needed**, generate a download script (`download-images-[project].js`) that:152 - Reads the clean JSON153 - Downloads each image URL with proper headers:154 ```javascript155 headers: {156 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'157 }158 ```159 - Saves to a local `images/` folder160 - Names files using the unique key/slug161 - Adds a delay between downloads (300-500ms) to be respectful162 - Updates the JSON with local file paths1631644. **Run the processing script** and show the user the results (total items, any removed, field summary).165166## Step 5: Optional HTML Generation167168If the user wants an HTML page from the data:169170- Generate a static HTML file with:171 - Filterable grid (by category, date, or custom field)172 - Responsive card layout173 - "Load More" pagination (show 20 at a time)174 - Clean styling that matches their project175- Use inline data (embed JSON in a `<script>` tag) for portability176- Include filter buttons and a search input if the dataset is large (50+ items)177178## Important Notes179180- Never scrape sites that explicitly prohibit it in robots.txt for the specific paths181- Never help bypass login, payment, access controls, CAPTCHAs, or rate limits182- Always include a User-Agent header when downloading images (many sites block without one)183- Add delays between requests to avoid overwhelming servers184- localStorage has a ~5MB limit (roughly 10,000-50,000 items depending on field count)185- If the user hits the localStorage limit, suggest splitting into batches and merging later186- The console script must be idempotent (safe to paste multiple times on the same page)