Puppeteer Scraper avatar

Puppeteer Scraper

Try for free

No credit card required

View all Actors
Puppeteer Scraper

Puppeteer Scraper

apify/puppeteer-scraper
Try for free

No credit card required

Crawls websites with the headless Chrome and Puppeteer library using a provided server-side Node.js code. This crawler is an alternative to apify/web-scraper that gives you finer control over the process. Supports both recursive crawling and list of URLs. Supports login to website.

Do you want to learn more about this Actor?

Get a demo
AK

Inject Jquery issue

Closed

assured_kumquat opened this issue
2 years ago

Hi,

It seems not possible to inject jquery as specified in the documentation.

What is the proper way do do that ?

1async function pageFunction(context) {
2    const { page, request, Apify } = context;
3
4    await Apify.utils.puppeteer.injectJQuery(page);
5
6//  "Apify.utils" is undefined
7    
8    return {
9        url: request.url,
10    };
11}

Thanks

adamek avatar

The method is now directly available in the crawling context and you no longer need to provide the page option as it gets used automatically:

https://crawlee.dev/api/puppeteer-crawler/interface/PuppeteerCrawlingContext#injectJQuery

1async function pageFunction(context) {
2    const { request, injectJQuery } = context;
3    await injectJQuery();
4
5    return {
6        url: request.url,
7    };
8}
adamek avatar

Where did you find the example? Current docs are correct, they only contain the contextual helper, so closing as answered. Be sure to read the latest version of the docs, sounds like you are viewing the old one for v2.

Developer
Maintained by Apify
Actor metrics
  • 345 monthly users
  • 61 stars
  • 99.8% runs succeeded
  • Created in Apr 2019
  • Modified 5 months ago