Created
March 19, 2016 07:05
-
-
Save sunapi386/7f521068ce48c5849083 to your computer and use it in GitHub Desktop.
Fetches blog from qqzone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://user.qzone.qq.com/765591203 | |
var pages = document.getElementById("tblog").contentWindow.document.getElementsByClassName("mod_pagenav_count")[0]; | |
var posts = document.getElementById("tblog").contentWindow.document.getElementById("listArea").getElementsByTagName("li"); | |
for (var i = 0; i < 1 /*posts.length*/; i++) { | |
var postTitle = posts[i].getElementsByClassName("article")[0].textContent; | |
var postLink = posts[i].getElementsByClassName("article")[0].getElementsByTagName("a")[0].href | |
// http://user.qzone.qq.com/765591203/blog/1400775512 | |
var entryDate = posts[i].getElementsByClassName("list_op")[0].childNodes[0].textContent; | |
var readCount = posts[i].getElementsByClassName("list_op")[0].childNodes[2].textContent; | |
console.log('--------------------------------------------------------') | |
console.log(postTitle, ",", entryDate, ",", readCount, ", ", postLink); | |
var iframe = document.createElement('iframe'); | |
iframe.onload = function() { | |
var win = iframe.contentWindow.document; | |
// Scraping | |
var iframe2 = win.getElementById("tblog").contentWindow.document; | |
var text = iframe2.getElementById('blogDetailDiv').children[0].textContent; | |
console.log(text); | |
console.log('^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'); | |
document.body.removeChild(iframe); | |
}; | |
iframe.src = postLink; | |
document.body.appendChild(iframe); | |
} | |
document.onload() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment