Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (async () => {
- //...
- try {
- //...
- // scroll to the bottom of the page
- await autoScroll(page);
- // retrieve HTML content
- const htmlContent = await page.content();
- // parse HTML using Cheerio
- const $ = cheerio.load(htmlContent);
- // extract desired data using Cheerio selectors
- $('.post').each((index, element) => {
- const title = $(element).find('h4').text().trim();
- const price = $(element).find('h5').text().trim();
- console.log(`item ${index + 1}: ${title}, ${price}`);
- });
- } catch (error) {
- console.error('Error:', error);
- } finally {
- await browser.close();
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement