const puppeteer = require("puppeteer");
(async function main() {
try {
const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage();
page.setUserAgent("Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36");
await page.goto("https://www.qimai.cn/rank/index/brand/all/genre/6014/device/iphone/country/us/date/2019-03-19", {waitUntil: 'load', timeout: 0});
await page.waitForSelector(".container");
const sections = await page.$$(".container");
const freeButton = await page.$('[href="/rank/index/brand/free/device/iphone/country/us/genre/6014/date/2019-03-19"]');
await freeButton.click();
// free list
const appTable = await page.waitForSelector(".data-table");
const lis = await page.$$(".data-table > tbody > tr > td");
// go to app content
const appInfo = await page.$("a.icon");
// appInfo.click();
for (const content of lis) {
const name = await content.$("div.appname");
const gameName = await page.evaluate(name => name.innerText, name);
console.log("Game Name: ", gameName);
}
console.log("-- bingo --");
} catch (e) {
console.log("our error", e);
}
})();
I cant seem to get the text from <div class="appname">
, and I'm getting this error:
TypeError: Cannot read property 'innerHTML' of null.
I have tried all ways, but it's not working.
This is the link to the website: https://www.qimai.cn/app/rank/appid/1451505313/country/us.