我正在尝试删除glassdoor公司的评论作为练习,并且我尝试学习javascript和JQuery以puppeteer
来做到这一点。在我的脚本中,我尝试将
(Pictures 1 and 2为摘要和日期的html位置)
但是,由于某种原因,只有摘要被打印到控制台,而日期却没有。如果有人指出我的代码有任何错误,我将非常感谢。
const puppeteer = require("puppeteer");
const cheerio = require('cheerio');
// puppeteer usage as normal
puppeteer.launch({ headless: false }).then(async browser => {
const page = await browser.newPage();
const navigationPromise = page.waitForNavigation();
await page.setViewport({ width: 1440, height: 794 }) ;
await page.goto('https://www.glassdoor.com/Reviews/Grubhub-Reviews-E419089.htm');
await navigationPromise;
var data = [];
const html = await page.content();
const $ = cheerio.load(html);
$(".hreview").each(function() {
console.log("\nMain scraping function happening...")
// This works
console.log($(this).find("span.summary").text());
// This does not work
console.log($(this).find("time.date").text());
});
await browser.close();
})