not able to call two different crawler with same url #2026
Unanswered
ganesh-swami
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Your code will reuse the same default/implicit const rq1 = await RequestQueue.open(); // default, will be purged automatically
const rq2 = await RequestQueue.open('rq2'); // named, we need to drop it at the end of the script
// code of CheerioCrawler:
const crawler = new CheerioCrawler({
requestQueue: rq1, // this is technically not necessary, default/implicit RQ is always there
async requestHandler({ $, request }) {
const title = $('title').text();
}
})
await crawler.run(['https://hanuman-chalisa.co.in/']);
//code of PlaywrightCrawler:
const crawler2 = new PlaywrightCrawler({
requestQueue: rq2, // using another RQ instance to have a separate state
requestHandler: async ({ page, parseWithCheerio }) => {
await page.waitForSelector('body h1');
const $ = await parseWithCheerio();
},
});
await crawler2.run(['https://hanuman-chalisa.co.in/']);
await rq2.drop(); // drop the named RQ, otherwise it would skip the requests processed in the previous run of the script |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Which package is this bug report for? If unsure which one to select, leave blank
None
Issue description
Why I do in this way :
Because i am checking if i didn't found content with CheerioCrawler it means it is using modern js tech stack and i have to get data of this using PlaywrightCrawler. So for some websites i have to call it both first cheerio and then playwright once cheerio is done. but it show bellow things for playwright => INFO PlaywrightCrawler: Finished! Total 0 requests: 0 succeeded, 0 failed. {"terminal":true}
Also i have checked and verify that second one doens't crawl at all .
Note :
What could be the possible solution. is this bug or i am expecting something which is not possible with crawlee.
Any help will be appreciated
Thanks
Code sample
Package version
3.5
Node.js version
18+
Operating system
windlow11
Apify platform
I have tested this on the
next
releaseNo response
Other context
No response
Beta Was this translation helpful? Give feedback.
All reactions