primary-violetP
Apify & Crawlee2y ago
5 replies
primary-violet

Want to scrap multiple elements on a web page

import { PlaywrightCrawler } from "crawlee";

const crawler = new PlaywrightCrawler({
  requestHandler: async ({ page, request, enqueueLinks }) => {
    console.log(`Processing: ${request.url}`);
    console.log(request.label);

    const title = await page
      .locator("span.nm-collections-row-name")
      .textContent();

    const results = {
      title,
    };

    console.log(results);
  },

  // Let's limit our crawls to make our tests shorter and safer.
  maxRequestsPerCrawl: 20,
});

await crawler.run(["https://www.netflix.com/in/browse/genre/1191605"]);

This is the code. Since there are multiple span tags in the web page so it is showing error. I want to get all the span tags. Can anyone help me
Was this page helpful?