Install the package using
npm install ts-scraper-2
The package will give you access to two Classes, Scrape
and Scraper
- hostname - The hostname of the domain you want to request. Ex. 'github.com'
- path - The endpoint you want to request at the given hostname. Use '/' for the root.
- scrapingFunction(response) - The function you define that will process the response you got from your request, where your scraped data is created.
- Sends an https request to the given address (
hostname
+path
) and calls thescrapingFunction
using the https response as the input. - Returns the result of the
scrapingFunction
- An Array of
Scrape
s that will be scraped in order whenscrapeAll()
is called.
- An array of the results returned by
Scrape.scrape()
whenscrapeAll()
is called.
- Value representing milliseconds between requests when
scrapeAll()
is called. Used to prevent overwhelming clients with requests and using up resources. Default value = 1000ms or 1 second/request.
- Add a
Scrape
Object to thequeuedScrapes
. You can also add an array ofScrape
s usingaddScrapes(scrapes: Scrape[])
- Goes through the
queuedScrapes
and callsScrape.scrape()
based on the setintervalTime
. Returned results are pushed intocompletedScrapes
.