Scraper.js Examples
Explore real-world examples of web scraping with Scraper.js
Basic Examples
Extracting All Links
Scrape all links from a page using attribute selectors
>
scraper.get('https://example.com')
.then($ => {
return $("a[href]").map((i, link) => $(link).attr('href')).get();
})
>
Extracting JSON Data
Extract and parse JSON embedded in HTML
>
scraper.get('https://example.com')
.then($ => {
const rawJson = $('.json-data').text();
const parsed = JSON.parse(rawJson);
return parsed;
})
>
Advanced Examples
Form Submission Scraper
Automate form filling and result extraction
>
scraper.post('https://example.com/login', {
username: 'test',
password: 'secret'
})
.then($ => {
return $('#auth-token').text();
})
>
API Scraper
Combine web scraping with API integration
>
scraper.get('https://api.example.com/data', {
headers: {
'Authorization': 'Bearer YOUR_TOKEN'
}
})
.then(data => {
return data.items.map(item => item.id);
})
>
Need Help??
Having trouble with an example? Check our full documentation or ask questions on GitHub!!