采集博客留言

2022/1/16 23:09:19

本文主要是介绍采集博客留言,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

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);

})();


这篇关于采集博客留言的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程