Add scrapeIt.fromStream function
See original GitHub issueWhat do you think of a fromStream function which feeds the HTML parser chunk by chunk instead of allocating one big string in memory?
I have already implemented it and am using it in one of my projects: https://github.com/IonicaBizau/scrape-it/compare/master...ComFreek:master.
I also have a unit test at hand, which requires an upgrade of the package tester, as already mentioned at https://github.com/IonicaBizau/tester/issues/15.
t.it("scrape from stream", cb => {
return t.expect(http.get(URL, response => {
scrapeIt.fromStream(response, {
title: "h1.title"
, description: ".description"
, date: {
selector: ".date"
, convert: x => new Date(x)
}
})
})).resolves.toEqual({
title: "Title"
, description: "Lorem ipsum"
, date: new Date("1988-01-01")
})
})
Open points:
- The normal
scrapeItmethod usescheerio-req, which actually could benefit from the chunk by chunk loading as well. - Investigate how htmlparser2 deals with encodings.
- [from a later comment] Wait for Cheerio adopting/discussing the
Cheerio.load(dom)public API: https://github.com/cheeriojs/cheerio/issues/1126
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Guarantee a Cheerio.load(dom) overload #1126 - GitHub
Add scrapeIt.fromStream function IonicaBizau/scrape-it#83 ... otherwise happy to add this as an additional method ( .stream or something)! ...
Read more >Python webscraping: HTML instead of Javascript function
Here the values in the HTML body are missing and there is just the JavaScript script. How can i scrape this values? Thanks....
Read more >Node.js Tips — Streams, Scraping, and Promisifying ...
Converting a Buffer into a ReadableStream in Node.js. We can convert a buffer to a readable stream with the ReadableStreamBuffer constructor.
Read more >Scrape the Web with Node.js + Finding Undocumented APIs ...
This is an archive of a live stream that was broadcasted on twitch: https://www.twitch.tv/codinggarden/ Donate: ...
Read more >How Web Scrape Multiple Pages with ONE Function with Python
Many websites use the same template for multiple pages of data, and this video shows you can create a single function to scrape...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

My code only stores the DOM tree in memory, not the HTML string. I think the DOM is necessary for CSS-like selectors in
scrape-itanyway.**) Actually, this exercise seems quite interesting: “Given a set of CSS selectors, does a program exist, which extracts the results from sequential HTML parsing?” or “Can we pre-compile a set of selectors, so that SAX-like parsing suffices to extract all the matches?”
I am going to close this, but contributions are welcome via PRs! 🚀