const puppeteer = require("puppeteer");
const url = "http://www.kuwo.cn/search/list?key=你";
(async () => {
const browser = await puppeteer.launch({
headless: false, //模拟浏览器行为
defaultViewport: null, //可视区域最大化
args: ['--start-maximized'] //浏览器窗口最大化
});
const page = await browser.newPage();
await page.goto(url)
await page.waitForTimeout(1000)
await autoScroll(page)
})();
function autoScroll(page) {
page.evaluate(()=>{
let distance = 50;
function go() {
setTimeout(() => {
var scrollHeight = document.body.clientHeight;
window.scrollTo(0, distance);
distance += 50;
console.log(distance)
if (distance < scrollHeight) {
go()
}
}, 100)
}
go()
})
}