各位好,前几天用下列程式码爬了这个粉专2017-2019的资料,但电脑一直转不确定是什么因素,可以请各位大神帮我看看是不是有什么问题,感激不尽!
https://www.facebook.com/equallovetw/
—————————————————————
var auto_slide = true;
let data = [];
function load_list()
{
if (!auto_slide) {
return
}
window.scroll(0, window.pageYOffset + 500);
showDetailArticle();
removeExtraArticle();
setTimeout(function () {
load_list();
}, 350);
}
function removeExtraArticle()
{
var rows = document.querySelectorAll(':not(li) > div[class="_4-u2 _4-u8"]');
if (rows.length < 40) {
return;
}
for (let s=0; s<= rows.length; s++) {
if (s >= 20) {
break;
}
if (rows[s] && rows[s].querySelector('abbr[data-utime]')) {
if (rows[s].querySelector('abbr[data-utime]').getAttribute('title').contains('2020')) {
rows[s].remove();
}
}
}
}
function showDetailArticle()
{
var rows = document.querySelectorAll(':not(li) > div[class="_4-u2 _4-u8"]');
for (let s=0; s<= rows.length; s++) {
if (rows[s] && rows[s].querySelector('abbr[data-utime]')) {
if (rows[s].querySelector('abbr[data-utime]').getAttribute('title').contains('2016')) {
auto_slide = false;
return;
}
if (
rows[s].querySelector('abbr[data-utime]').getAttribute('title').contains('2019')
|| rows[s].querySelector('abbr[data-utime]').getAttribute('title').contains('2018')
|| rows[s].querySelector('abbr[data-utime]').getAttribute('title').contains('2017')
) {
if (rows[s].querySelector('.see_more_link_inner')) {
rows[s].querySelector('.see_more_link_inner').click();
}
setTimeout(function () {
this.target.classList.add('more-clicked');
}.bind({
target: rows[s],
}), 500);
rows[s].classList.add('more-clicking');
}
}
}
}
function download(data) {
const filename = 'output.tsv';
const blob = new Blob([data], {type: 'text/json'});
const e = document.createEvent('MouseEvents');
const a = document.createElement('a');
a.download = filename;
a.href = window.URL.createObjectURL(blob);
a.dataset.downloadurl = ['text/json', a.download, a.href].join(':');
e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
a.dispatchEvent(e);
}
function captureArticle()
{
console.log('zzzzzzz');
var rows = document.querySelectorAll(':not(li) > div._4-u2._4-u8.more-clicked');
for (let s=0; s< rows.length; s++) {
if (rows[s] && rows[s].querySelector('[data-testid="post_message"]') && rows[s].querySelector('abbr[data-utime]')) {
// console.log('