Monday, 3 April 2017

How do I make a HTTP request (for scraping purposes) to an Angular2 site?

I'm trying to use a node server to scrape some information from an agular2 Application. The problem is that the response I get is the index.js file, essentially the "loading..." part of the page.

I'm using the npm request or request-promise package like this:

var rp = require("request-promise");

rp('https://someurl.com')
    .then((html) => {
        // Do something with the response
    })
    .catch((err) => {
        console.log(err);
    })

But I can't figure out if it is possible to wait for the page to actually load. I've looked at possibly using Angular Universal but I need to get the data after it has all loaded and the site owner is against using Universal.

Is there anyway to make this work?



via Notmfb

No comments:

Post a Comment