2023-06-12 15:20:45 +08:00
|
|
|
|
const puppeteer = require("puppeteer")
|
|
|
|
|
const { seep } = require("../utils.js");
|
|
|
|
|
|
2023-06-14 15:43:04 +08:00
|
|
|
|
async function getQqListData(url) {
|
2023-06-12 15:20:45 +08:00
|
|
|
|
const browser = await puppeteer.launch({
|
|
|
|
|
// 关闭无头模式,方便我们看到这个无头浏览器执行的过程
|
|
|
|
|
headless: false,
|
|
|
|
|
timeout: 0 // 默认超时为30秒,设置为0则表示不设置超时
|
|
|
|
|
});
|
|
|
|
|
const page = await browser.newPage();
|
|
|
|
|
page.setViewport({
|
|
|
|
|
width: 1376,
|
|
|
|
|
height: 768,
|
|
|
|
|
});
|
|
|
|
|
await page.goto(url, {});
|
|
|
|
|
let list = await page.evaluate(() => {
|
|
|
|
|
return window.__PINIA__.episodeMain
|
|
|
|
|
})
|
2023-06-14 15:43:04 +08:00
|
|
|
|
// let qb = await page.$$(".b-btn--round")
|
|
|
|
|
await page.$$eval(".b-btn--round", (list) => {
|
|
|
|
|
console.log(list)
|
|
|
|
|
for (let i of list) {
|
|
|
|
|
if (i && i.innerText) {
|
|
|
|
|
if ("全部" == i.innerText.trim()) {
|
|
|
|
|
i.click()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
2023-06-12 15:20:45 +08:00
|
|
|
|
for (let i of list.listData[0].tabs) {
|
|
|
|
|
let text = i.text
|
|
|
|
|
let more = await page.$(".b-tab__more")
|
|
|
|
|
more && more.click()
|
|
|
|
|
await page.$$eval(".b-tab__item", (list, text) => {
|
|
|
|
|
console.log(list)
|
|
|
|
|
for (let i of list) {
|
|
|
|
|
if (i && i.innerText) {
|
|
|
|
|
if (text == i.innerText.trim()) {
|
|
|
|
|
i.click()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, text)
|
2023-06-14 15:43:04 +08:00
|
|
|
|
await page.$$eval(".b-tag-list__tag", (list, text) => {
|
|
|
|
|
console.log(list)
|
|
|
|
|
for (let i of list) {
|
|
|
|
|
if (i && i.innerText) {
|
|
|
|
|
if (text == i.innerText.trim()) {
|
|
|
|
|
i.click()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, text)
|
2023-06-12 15:20:45 +08:00
|
|
|
|
await seep(1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list = await page.evaluate(() => {
|
|
|
|
|
return __PINIA__.episodeMain
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
list = list.listData[0].list
|
|
|
|
|
let listData = []
|
|
|
|
|
for (let i of list) {
|
|
|
|
|
// listData.push(...i)
|
|
|
|
|
i.forEach(j => {
|
|
|
|
|
if(!j.isNoStoreWatchHistory){
|
|
|
|
|
listData.push(j)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
list = []
|
|
|
|
|
for(let i of listData){
|
|
|
|
|
list.push({
|
|
|
|
|
title:i.fullTitle,
|
|
|
|
|
url:"https://v.qq.com/x/cover/" + i.cid + "/" + i.vid + ".html"
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
browser.close()
|
|
|
|
|
return list
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
2023-06-14 15:43:04 +08:00
|
|
|
|
getQqListData
|
2023-06-12 15:20:45 +08:00
|
|
|
|
}
|