Ad

Scroll Down When Scraping With Phantom ( Node.js )

- 1 answer

I'm using phantom to scrape a dynamic web page content and i need to scroll down to display all of the page content .

I've tried this await page.property('scrollPosition', { top: 1000, left: 0 }); but it didn't work for me and the content still the same.

this is my code :

(async function() {
    const instance = await phantom.create();
    const page = await instance.createPage();
    await page.on("onResourceRequested", function(requestData) {
      //console.info("Requesting", requestData.url);
    });

    const status = await page.open(
      "https://www.articles-epresse.fr/media/894eab75-c642-46a2-a1ba-b240c278ebbc?"
    );

    if (status == "success") {
      await page.property("scrollPosition", {
        top: 1000,
        left: 0
      });
    }
    const content = await page.property("content");

    console.log(content);
    var $ = cheerio.load(content);

Any idea ?

Ad

Answer

i just needed to increment the value of top to 3000 so it could scrape the rest of the page

Ad
source: stackoverflow.com
Ad