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.

User avatar

Inject Jquery issue

Closed

assured_kumquat opened this issue
a year 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

User 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}
User 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
  • 285 monthly users
  • 99.8% runs succeeded
  • 15 days response time
  • Created in Apr 2019
  • Modified about 1 month ago