Web Scraper Headless allows to extract data from web pages using plans (sitemaps) created with the Web Scraper browser extension. Using these sitemaps the Web Scraper will navigate the site accordingly and extract all data. Scraped data later can be exp
npm install web-scraper-headlessTo use it as an extension install it from [Chrome store] [chrome-store]
To use it as a library do npm i web-scraper-headless
1. Scrape multiple pages
2. Sitemaps and scraped data are stored in browsers local storage or in CouchDB
3. Multiple data selection types
4. Extract data from dynamic pages (JavaScript+AJAX)
5. Browse scraped data
6. Export scraped data as CSV
7. Import, Export sitemaps
8. Depends only on Chrome browser
Documentation and tutorials are available on [webscraper.io] [webscraper.io]
Ask for help, submit bugs, suggest features on [google groups] [google-groups]
Submit bugs and suggest features on [bug tracker] [github-issues]
#### Headless mode
To use it as a library you need a sitemap, you can write it by hand, but the easiest way is to use the [original extension][extension] to scrape and then click on "export sitemap".
const webscraper = require('web-scraper-headless')
// visit github and retrieve last commit of all trending repo.
// The sitemap depends on the actual DOM of github, so it might get outdated
const sitemap = {
"startUrl": "https://github.com/trending",
"selectors": [{
"parentSelectors": ["_root"],
"type": "SelectorLink",
"multiple": true,
"id": "link_to_repo",
"selector": "h3 a",
"delay": ""
}, {
"parentSelectors": ["link_to_repo"],
"type": "SelectorText",
"multiple": false,
"id": "latest_commit",
"selector": "a.commit-tease-sha",
"regex": "",
"delay": ""
}],
"_id": "github_trending"
}
const options = {delay: 10, pageLoadDelay: 10, browser: 'headless'} // optional delay, pageLoadDelay and browser
webscraper(sitemap, options)
.then(function (scraped) {
// This is your scraped info
})
By default webscraper-headless will open jsdom as a browser. This is a purely JS implementation of HTML. As such it has no native dependencies and it is very lightweighted. However, it is not capable of executing js which might be a hindrance in some cases. If that is your case, you can use chrome headless as a browser. Note that it will consume far more resources than jsdom and you need to have some native dependencies installed in the server. To use chrome headless do the following:
const sitemap = // same as previous example
const options = {browser: 'headless'}
webscraper(sitemap, options)
.then(function (scraped) {
// This is your scraped info
})
#### Bugs
When submitting a bug please attach an exported sitemap if possible.
[chrome-store]: https://chrome.google.com/webstore/detail/web-scraper/jnhgnonknehpejjnehehllkliplmbmhn
[webscraper.io]: http://webscraper.io/
[google-groups]: https://groups.google.com/forum/#!forum/web-scraper
[github-issues]: https://github.com/martinsbalodis/web-scraper-chrome-extension/issues
[extension]: https://chrome.google.com/webstore/detail/web-scraper/jnhgnonknehpejjnehehllkliplmbmhn