Skip to content

Commit 1df3139

Browse files
committed
move to parseWithCheerio
1 parent 3cbe661 commit 1df3139

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

content/academy/expert_scraping_with_apify/solutions/actor_building.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,10 @@ Let's try it out now! Input **iphone** into the box labeled **keyword**, click *
468468

469469
**Q: When using Puppeteer or Playwright, how can you still use jQuery with Crawlee?**
470470

471-
**A:** There are two ways. You can either use the [injectJQuery](https://crawlee.dev/api/playwright-crawler/namespace/playwrightUtils#injectJQuery) utility function which will enable you to use jQuery inside of `page.evaluate()`, or you can use Cheerio to load the page's content like this:
471+
**A:** There are two ways. You can either use the [injectJQuery](https://crawlee.dev/api/playwright-crawler/namespace/playwrightUtils#injectJQuery) utility function which will enable you to use jQuery inside of `page.evaluate()`, or you can use Cheerio to load the page's content with the [`parseWithCheerio`](https://crawlee.dev/api/playwright-crawler/namespace/playwrightUtils#parseWithCheerio) function:
472472

473473
```JavaScript
474-
const $ = cheerio.load(await page.content());
474+
const $ = await parseWithCheerio();
475475
```
476476

477477
Which will allow you to use jQuery syntax outside of Puppeteer/Playwright page evaluation functions.
@@ -503,7 +503,7 @@ const title = await page.evaluate(() => document.querySelector('title').textCont
503503
It is still much more preferred to go with this option:
504504

505505
```JavaScript
506-
const $ = cheerio.load(await page.content());
506+
const $ = await parseWithCheerio();
507507
const title = $('title').text();
508508
```
509509

content/academy/web_scraping_for_beginners/crawling/dealing_with_dynamic_pages.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ const BASE_URL = 'https://demo-webstore.apify.org';
106106
// Switch CheerioCrawler to PuppeteerCrawler
107107
const crawler = new PuppeteerCrawler({
108108
// Replace "$" with "page"
109-
requestHandler: async ({ page, request }) => {
110-
// Create the $ object based on the page's content
111-
const $ = cheerio.load(await page.content());
109+
requestHandler: async ({ parseWithCheerio, request }) => {
110+
// Create the $ Cheerio object based on the page's content
111+
const $ = await parseWithCheerio();
112112

113113
const products = $('a[href*="/product/"]');
114114

@@ -150,11 +150,11 @@ import cheerio from 'cheerio';
150150
const BASE_URL = 'https://demo-webstore.apify.org';
151151

152152
const crawler = new PuppeteerCrawler({
153-
requestHandler: async ({ page, request }) => {
153+
requestHandler: async ({ parseWithCheerio, request }) => {
154154
// Add the utility function
155155
await utils.puppeteer.infiniteScroll(page);
156156

157-
const $ = cheerio.load(await page.content());
157+
const $ = await parseWithCheerio();
158158

159159
const products = $('a[href*="/product/"]');
160160

0 commit comments

Comments
 (0)