需要制作一个JavaScript爬取脚本
https://www.52pojie.cn/thread-1972660-1-1.html
(出处: 吾爱破解论坛)
大家帮忙看看不使用下面这个接口有没有办法获取指定的信息
http://service.bot.qch86.top:8100/activation/code/${page}
获取激活码列表中所有2天、1天、0天前更新的激活码的JavaScript
[i]
[JavaScript] 纯文本查看 复制代码const days = 2
const today = new Date(new Date().setHours(0, 0, 0, 0))
const oneDay = 86400 * 1000
const daysMap = {
"今": today,
"昨": today - oneDay,
}
let list = []
const activationList = document.querySelectorAll(.activation-list .activation)
async function getList() {
const activationList = setNewList(document.querySelectorAll(.activation-list .activation))
list = [...filterData(activationList,days)]
console.log(list)
if (!list.length){
return alert(没有数据)
} else {
const result = list.map(item => {
return item.content
}).join(n)
alert(result)
}
}
const setNewList = (data) => {
return Array.prototype.map.call(data, item => {
const createTime = daysMap[item.children[0].innerText.split(天)[0]] ? daysMap[item.children[0].innerText.split(天)[0]] : today - oneDay * item.children[0].innerText.split(天)[0]
console.log(createTime);
return {
createTime,
content: item.children[1].innerText
}
})
}
// 过滤掉days之前的数据
const filterData = (data, days) => {
const dates = new Date(new Date().setHours(0, 0, 0, 0))
return data.filter(item => {
console.log(dates - new Date(item.createTime).getTime() {
// 创建观察器
const observer = new MutationObserver(mutations => {
getList()
})
observer.observe(document.querySelector(.activation-list), {
childList: true
})
}
window.onload = createObserver()
但是报错;
不通过接口获取激活码.user.js:18 Uncaught SyntaxError: Unexpected token . (at 不通过接口获取激活码.user.js:18:50)
at async Wt (injected.js:1:8803)
at async injected.js:1:14574