凤凰网上看书很不方便,不允许复制粘贴,而且每章节都是通过ajax请求超慢。就写个脚本,直接导出整本书到html页面上。
每个页面都有书的id和章节id,根据这些请求同一个url得到章节内容。
function getBookContent(bookId, fromChapterId, toChapterId ) {
var str = '';
function getChapterContent() {
if (fromChapterId > toChapterId) {
console.log(str);
var web = window.open('');
web.document.body.innerHTML = str;
return;
}
$.ajax({
url: 'http://v.book.ifeng.com/read/book/remc.htm',
type: 'post',
data: {b: bookId, c:fromChapterId++},
success: function(data) {
str += data.content;
getChapterContent(fromChapterId);
}
});
}
getChapterContent();
}
getBookContent(31015, 2268373, 2268397);