Re:Show HN: Headless Chrome Crawler
by bryanrasmussen on Thursday February 22, 2018 @09:08AM
(#16437591)
Can't see from examples, how do I get back individual elements from the body?
[ Parent
| on HN ]
Not a user of this tool, but https://github.com/yujiosaka/headless-chrome-crawler#event-n... points to https://github.com/GoogleChrome/puppeteer/blob/master/docs/a... where you can grab elements.
Basically, when new page event happens, you get the `page` object where you have access to it and can do queries.
`page.$(query)` or `page.$$(queryAll)` to be more specific
https://github.com/GoogleChrome/puppeteer/blob/v1.1.0/docs/a...
Re:Show HN: Headless Chrome Crawler
by bryanrasmussen on Thursday February 22, 2018 @04:03PM
(#16441368)
yes I've used puppeteer, but I couldn't see where it exposed the page object, but looking closer I saw
HCCrawler.launch({ // Function to be evaluated in browsers evaluatePage: (() => ({ title: $('title').text(), })), // Function to be called with evaluated results from browsers onSuccess: (result => { console.log(result); }), })
which doesn't look that good for my other worry, that you come to a dynamic JS built up page, load the DOM and evaluate in some milliseconds and then that DOM is changed after you've done your incorrect evaluation.