我正在尝试解析imdb电影连接(https://www.imdb.com/title/tt0090887/movieconnections/),但更多按钮不会加载每个类别中的信息(精选于,followeb by.. .)。 Puppeteer 点击功能不起作用,因为它是一种 javascript 功能
const puppeteer = require('puppeteer');
const scrape = 异步函数 () { const browser = wait puppeteer.launch({ headless: false });
const page = await browser.newPage();
await page.goto('https://www.imdb.com/title/tt0090887/movieconnections/');
await page.click('.ipc-see-more__button');
我现在有这个代码:
const puppeteer = require('puppeteer');
const scrape = async function () {
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
await page.goto('https://www.imdb.com/title/tt0090887/movieconnections/');
await page.waitForSelector('.ipc-see-more__button');
// await page.click('.ipc-see-more__button');
await page.evaluate(() => {
const buttons = document.querySelectorAll('button')
buttons.forEach(button => {
if(button.className.includes(".ipc-see-more__button")) {
button.click()
}
})
})
// logging results
// console.log(quotes);
// await browser.close();
};
scrape()
但没有按下按钮