scraperjs | A complete and versatile web scraper | Reactive Programming library
kandi X-RAY | scraperjs Summary
kandi X-RAY | scraperjs Summary
Scraperjs uses promises whenever possible. So, the scrapers should be used with the ScraperPromise. By creating a scraper. The following promises can be made over it, they all return a scraper promise,. All callback functions receive as their last parameter a utils object, with it the parameters of an url from a router can be accessed. Also the chain can be stopped. The promise chain is fired with the same sequence it was declared, with the exception of the promises get and request that fire the chain when they've received a valid response, and the promises done and catch, which were explained above. You can also waterfall values between promises by returning them (with the exception of the promise timeout, that will always return undefined) and it can be access through utils.lastReturn.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of scraperjs
scraperjs Key Features
scraperjs Examples and Code Snippets
Community Discussions
Trending Discussions on scraperjs
QUESTION
I tried to make a scraper using ruipgil/scraperjs function that is asynchronous. But when I put it inside a loop, it got jammed and won't work. I'm new to Node and the idea of asynchronous programming so please bear with me.
So, I have this code:
...ANSWER
Answered 2017-Oct-28 at 02:40You could try using recursion so that it doesn't get stuck in that while loop?
QUESTION
My first attempt at a basic node app.
If I test run this file (> node index.js) with console.log(eventsArray) in it instead, the array successfully prints out data from the scraper module in the command window, so my scraper module is working.
And if I set eventsArray = ['this','is,'a','test','array']; in index.js as a test, then these strings do show up on homepage like I want after running the app with Express, so Express + Jade template are working (no need to include my ejs template here since it's working).
The problem: If I try to run the app as shown below (> node index.js), eventsArray appears to be 'undefined' when it's passed into the res.render function, so nothing shows up on localhost:3000 (homepage)
index.js:
...ANSWER
Answered 2017-Sep-05 at 12:53Your getEvents
returns nothing, besides of this scraperjs.StaticScraper.create
is async function it returns a promise.
You should return async result from getEvents
:
QUESTION
Stuck on my first attempt at a basic app. Scraper.js scrapes a URL and writes the returned array to the document obj when run alone in console, so that part works. Now all I want is an Express server to run the script whenever I open localhost:3000 but not sure how to do so.
...ANSWER
Answered 2017-Sep-01 at 23:34Here is a one that i've coded with promises, and also using a global variable which is daNews
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install scraperjs
a StaticScraper, that is light fast and with a low footprint, however it doesn't allow for more complex situations, like scraping dynamic content.
a DynamicScraper, that is a bit more heavy, but allows you to scrape dynamic content, like in the browser console. both scrapers expose a very similar API, with some minor differences when it comes to scraping.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page