如何下载web资源
2021-04-21 13:26
标签:bat lse deb course debug rip post cti cond 目录 如何下载web资源 最近机工社宣布开放工程科技数字图书馆, 全网免费共克时艰! 发现有些书是以web页面的方式给用户看的,一张一张,很难一次性下载 有没有办法一次性下载他们呢? 比如书 上网查到很多chrome extension但是他们都认不到页面内的连接。这是因为页面里面根本没有连接 biru 页面链接如下 该链接其实最终变成http://www.hzcourse.com/resource/readBook?path=/openresources/teach_ebook/uncompressed/13780/OEBPS/Text/chapter33.html 所以怪不得扩展不认识了 看来还是要自己写一个了 最简单就是用python了 测试以上链接 成功! Test result A: avalonjs 万能的chrome F12了 如何下载web资源 标签:bat lse deb course debug rip post cti cond 原文地址:https://www.cnblogs.com/cutepig/p/12250629.html
目的
研究
test 1: chrome extension
3.1 协商原则
C:\Users\cutep>python -m wget http://www.hzcourse.com/resource/readBook?path=/openresources/teach_ebook/uncompressed/13780/OEBPS/Text/chapter33.html -o 33.html
100% [................................................................................] 4000 / 4000
Saved under 33.html
test 2: 最终写了如下python脚本
import os
#from selenium import webdriver
#from urllib2 import urlopen
import requests
def my_system(cmd):
print(cmd)
os.system(cmd)
def download(url, file):
cmd = 'python -m wget %s -o %s'%(url, file)
my_system(cmd)
def download_chapter(click_url, file):
download('http://www.hzcourse.com/resource/readBook?path=%s'%click_url, file)
def get_bookname(cont):
s='
Saved under chapter51.xhtml
/openresources/teach_ebook/uncompressed/16571/OEBPS/Text/chapter52.xhtml chapter52.xhtml
python -m wget http://www.hzcourse.com/resource/readBook?path=/openresources/teach_ebook/uncompressed/16571/OEBPS/Text/chapter52.xhtml -o chapter52.xhtml
100% [................................................................................] 1058 / 1058
Saved under chapter52.xhtml
/openresources/teach_ebook/uncompressed/16571/OEBPS/Text/chapter53.xhtml chapter53.xhtml
python -m wget http://www.hzcourse.com/resource/readBook?path=/openresources/teach_ebook/uncompressed/16571/OEBPS/Text/chapter53.xhtml -o chapter53.xhtml
100% [................................................................................] 4625 / 4625
Saved under chapter53.xhtml
/openresources/teach_ebook/uncompressed/16571/OEBPS/Text/chapter54.xhtml chapter54.xhtml
python -m wget http://www.hzcourse.com/resource/readBook?path=/openresources/teach_ebook/uncompressed/16571/OEBPS/Text/chapter54.xhtml -o chapter54.xhtml
100% [..................................................................................] 705 / 705
Saved under chapter54.xhtml
/openresources/teach_ebook/uncompressed/16571/OEBPS/Text/chapter55.xhtml chapter55.xhtml
python -m wget http://www.hzcourse.com/resource/readBook?path=/openresources/teach_ebook/uncompressed/16571/OEBPS/Text/chapter55.xhtml -o chapter55.xhtml
100% [................................................................................] 1814 / 1814
Saved under chapter55.xhtml
/openresources/teach_ebook/uncompressed/16571/OEBPS/Text/chapter56.xhtml chapter56.xhtml
python -m wget http://www.hzcourse.com/resource/readBook?path=/openresources/teach_ebook/uncompressed/16571/OEBPS/Text/chapter56.xhtml -o chapter56.xhtml
100% [..............................................................................] 10025 / 10025
Saved under chapter56.xhtml
/openresources/teach_ebook/uncompressed/16571/OEBPS/Text/chapter57.xhtml chapter57.xhtml
python -m wget http://www.hzcourse.com/resource/readBook?path=/openresources/teach_ebook/uncompressed/16571/OEBPS/Text/chapter57.xhtml -o chapter57.xhtml
其他
下面这个是啥框架写的?
bookChapter在哪里定义的?
var probation = {
search:function(){
var key = $.trim($("#condition").val());
ebookRead.queryEbookChapterList(key);
},
queryEbookChapterList:function(key){
var ebookId = $.trim($("#ebookId").val());
var token = $.trim($("#token").val());
debugger;
jQuery.ajax({
type : "post" ,
url : "web/refbook/queryAllChapterList",
dataType : "json" ,
data : {ebookId:ebookId,key:key,token:token},
success : function(obj) {
if(obj.data.code==1){
var bookChapters = obj.data.data;
if(bookChapters.length > 0){
bookChaptertCtrl.bookChapters = bookChapters;
$("#chapterCont").load();
$("#directories").find("li").first().children("a").click();
}
} else {
alert(obj.data.message);
}
}
});
},
如何获取连接?