其他分享
首页 > 其他分享> > 采集博客留言

采集博客留言

作者:互联网

document-end 作用不大。。。有点尴尬

// ==UserScript==
// @name         cnblogs采集
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://www.cnblogs.com/marklove/articles/14425477.html
// @icon         https://www.google.com/s2/favicons?domain=cnblogs.com
// @grant        none
// @run-at document-end
// ==/UserScript==

(function() {
 function utf8ToBase64(str){
  return btoa(unescape(encodeURIComponent(str)));
}
var s2 = document.querySelectorAll("*[class^='blog_comment_body cnblogs-markdown']")
var ss_LinkList = [];
for (var i=0; i<s2.length; i++) {
    var obj = s2[i].querySelector("p");
    ss_LinkList.push('\n'+obj.innerText);
    //ss_LinkList.push('——'+s2[i].children[1].innerText+'——'+s2[i].children[2].innerText+'——'+s2[i].children[3].innerText+'——'+s2[i].children[4].innerText);
}
console.log(s2.length)
console.log(ss_LinkList.join('\n'))

alert(ss_LinkList.join('\n'))

setTimeout(function(){
//	console.log(document.documentElement.outerHTML);
    var s2 = document.querySelectorAll("*[class^='blog_comment_body cnblogs-markdown']")
var ss_LinkList = [];
for (var i=0; i<s2.length; i++) {
    var obj = s2[i].querySelector("p");
    ss_LinkList.push('\n'+obj.innerText);
    //ss_LinkList.push('——'+s2[i].children[1].innerText+'——'+s2[i].children[2].innerText+'——'+s2[i].children[3].innerText+'——'+s2[i].children[4].innerText);
}
console.log(s2.length)
//console.log(ss_LinkList.join('\n'))
document.getElementById("tbCommentBody").innerHTML =ss_LinkList.join('\n');
/*
    alert(ss_LinkList.join('\n'));
    window.alert("sometext");
    window.confirm("sometext");

    var r = confirm("请按按钮");
if (r == true) {
    x = "您按了确认!";
} else {
    x = "您按了取消!";
}
window.prompt("sometext","defaultText");

    var person = prompt("请输入您的姓名", "比尔盖茨");
if (person != null) {
    document.getElementById("tbCommentBody").innerHTML = "你好 " + person + "!今天过的怎么样?";
}
    usagealert("sample text");
*/
},10000);

})();

标签:www,cnblogs,留言,博客,采集,https,var,document,com
来源: https://www.cnblogs.com/marklove/p/15811493.html