首先在课堂派资料PDF文件下载这个博主的帮助下,知道了手动下载的办法,在这个基础上,写一点代码,省点力气
首先确定下,这个暂时只适用这种文件,并且也不是下载PDF,最后会有一堆图片
-
把课堂派中的PDF浏览一遍,确定全部都缓存了
-
F12,然后搜 img?img= ,把包含搜索结果的代码多复制一点,包含就行,然后把下面代码里面的HTML替换
# 把一个老师上传的pdf弄下来 import re import urllib.request html = """<div id="ctn" data-scale="100" style="margin-top: 36px; width: 945px; margin-left: 0px; overflow: hidden scroll; position: absolute; height: 830px;"> <div id="p0" data-page="8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtevFHvsSsg6nH3TlcLPhtH8=" data-width="880" data-height="1139" style="margin: auto auto 10px; width: 880px; height: 1139px;"><img src="img?img=8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtevFHvsSsg6nH3TlcLPhtH8=&tp=" style="position: absolute; width: 880px; height: 1139px;"><canvas id="p0_vas" width="880px" height="1139px" style="z-index: 999; position: absolute;"></canvas><canvas id="p0_vas_0" width="880px" height="1139px" style="z-index: 996; position: absolute;"></canvas> <div style="position: absolute; width: 880px; height: 1139px;"></div> </div> <div id="p1" data-page="8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtUMaeuhacYMve9d5jWogwFY=" data-width="880" data-height="1139" style="margin: auto auto 10px; width: 880px; height: 1139px;"><img src="img?img=8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtUMaeuhacYMve9d5jWogwFY=&tp=" style="position: absolute; width: 880px; height: 1139px;"><canvas id="p1_vas" width="880px" height="1139px" style="z-index: 999; position: absolute;"></canvas><canvas id="p1_vas_0" width="880px" height="1139px" style="z-index: 996; position: absolute;"></canvas> <div style="position: absolute; width: 880px; height: 1139px;"></div> </div> <div id="p2" data-page="8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvteulZPjF8G8KMCQPwxQxej8=" data-width="880" data-height="1139" style="margin: auto auto 10px; width: 880px; height: 1139px;"><img src="img?img=8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvteulZPjF8G8KMCQPwxQxej8=&tp=" style="position: absolute; width: 880px; height: 1139px;"><canvas id="p2_vas" width="880px" height="1139px" style="z-index: 999; position: absolute;"></canvas><canvas id="p2_vas_0" width="880px" height="1139px" style="z-index: 996; position: absolute;"></canvas> <div style="position: absolute; width: 880px; height: 1139px;"></div> </div> <div id="p3" data-page="8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtYnv@O626J0X5GN8_6eedwc=" data-width="880" data-height="1139" style="margin: auto auto 10px; width: 880px; height: 1139px;"><img src="img?img=8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtYnv@O626J0X5GN8_6eedwc=&tp=" style="position: absolute; width: 880px; height: 1139px;"><canvas id="p3_vas" width="880px" height="1139px" style="z-index: 999; position: absolute;"></canvas><canvas id="p3_vas_0" width="880px" height="1139px" style="z-index: 996; position: absolute;"></canvas> <div style="position: absolute; width: 880px; height: 1139px;"></div> </div> <div id="p4" data-page="8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvta3r4mTrH@690z7ZuWcX2A4=" data-width="880" data-height="1139" style="margin: auto auto 10px; width: 880px; height: 1139px;"><img src="img?img=8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvta3r4mTrH@690z7ZuWcX2A4=&tp=" style="position: absolute; width: 880px; height: 1139px;"><canvas id="p4_vas" width="880px" height="1139px" style="z-index: 999; position: absolute;"></canvas><canvas id="p4_vas_0" width="880px" height="1139px" style="z-index: 996; position: absolute;"></canvas> <div style="position: absolute; width: 880px; height: 1139px;"></div> </div> <div id="p5" data-page="8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtV2Anca4iJyLYcJmlTN@7Ac=" data-width="880" data-height="1139" style="margin: auto auto 10px; width: 880px; height: 1139px;"><img src="img?img=8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtV2Anca4iJyLYcJmlTN@7Ac=&tp=" style="position: absolute; width: 880px; height: 1139px;"><canvas id="p5_vas" width="880px" height="1139px" style="z-index: 999; position: absolute;"></canvas><canvas id="p5_vas_0" width="880px" height="1139px" style="z-index: 996; position: absolute;"></canvas> <div style="position: absolute; width: 880px; height: 1139px;"></div> </div> <div id="p6" data-page="8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtVCMm5j9t2GlZBVI_YaGlUk=" data-width="880" data-height="1139" style="margin: auto auto 10px; width: 880px; height: 1139px;"><img src="img?img=8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtVCMm5j9t2GlZBVI_YaGlUk=&tp=" style="position: absolute; width: 880px; height: 1139px;"><canvas id="p6_vas" width="880px" height="1139px" style="z-index: 999; position: absolute;"></canvas><canvas id="p6_vas_0" width="880px" height="1139px" style="z-index: 996; position: absolute;"></canvas> <div style="position: absolute; width: 880px; height: 1139px;"></div> </div> <div id="p7" data-page="8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtbkQruzAuSUOBPiXCWJhLuc=" data-width="880" data-height="1139" style="margin: auto auto 10px; width: 880px; height: 1139px;"><img src="img?img=8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtbkQruzAuSUOBPiXCWJhLuc=&tp=" style="position: absolute; width: 880px; height: 1139px;"><canvas id="p7_vas" width="880px" height="1139px" style="z-index: 999; position: absolute;"></canvas><canvas id="p7_vas_0" width="880px" height="1139px" style="z-index: 996; position: absolute;"></canvas> <div style="position: absolute; width: 880px; height: 1139px;"></div> </div> <div id="p8" data-page="8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtc9FHlzbY0BD6CfZGQSMg3U=" data-width="880" data-height="1139" style="margin: auto auto 10px; width: 880px; height: 1139px;"><img src="img?img=8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtc9FHlzbY0BD6CfZGQSMg3U=&tp=" style="position: absolute; width: 880px; height: 1139px;"><canvas id="p8_vas" width="880px" height="1139px" style="z-index: 999; position: absolute;"></canvas><canvas id="p8_vas_0" width="880px" height="1139px" style="z-index: 996; position: absolute;"></canvas> <div style="position: absolute; width: 880px; height: 1139px;"></div> </div> <div id="p9" data-page="8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtc60VwDn38xlhIwSUOZ3eRY=" data-width="880" data-height="1139" style="margin: auto auto 10px; width: 880px; height: 1139px;"><img src="img?img=8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtc60VwDn38xlhIwSUOZ3eRY=&tp=" style="position: absolute; width: 880px; height: 1139px;"><canvas id="p9_vas" width="880px" height="1139px" style="z-index: 999; position: absolute;"></canvas><canvas id="p9_vas_0" width="880px" height="1139px" style="z-index: 996; position: absolute;"></canvas> <div style="position: absolute; width: 880px; height: 1139px;"></div> </div> <div id="p10" data-page="8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtebsPUvS9I7jKXBxAc6QuLw=" data-width="880" data-height="1139" style="margin: auto auto 10px; width: 880px; height: 1139px;"><img src="img?img=8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtebsPUvS9I7jKXBxAc6QuLw=&tp=" style="position: absolute; width: 880px; height: 1139px;"><canvas id="p10_vas" width="880px" height="1139px" style="z-index: 999; position: absolute;"></canvas><canvas id="p10_vas_0" width="880px" height="1139px" style="z-index: 996; position: absolute;"></canvas> <div style="position: absolute; width: 880px; height: 1139px;"></div> </div> <div id="p11" data-page="8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtYj9NnHCelIL3eWJYsDng9k=" data-width="880" data-height="1139" style="margin: auto auto 10px; width: 880px; height: 1139px;"><img src="img?img=8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtYj9NnHCelIL3eWJYsDng9k=&tp=" style="position: absolute; width: 880px; height: 1139px;"><canvas id="p11_vas" width="880px" height="1139px" style="z-index: 999; position: absolute;"></canvas><canvas id="p11_vas_0" width="880px" height="1139px" style="z-index: 996; position: absolute;"></canvas> <div style="position: absolute; width: 880px; height: 1139px;"></div> </div> <div id="p12" data-page="8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtbp@2wFJy0nOPaAOwU8QNDA=" data-width="880" data-height="1139" style="margin: auto auto 577.333px; width: 880px; height: 1139px;"><img src="img?img=8BTy2gSXw1JSxbjh3PUgUHBas8dNnLh@Mmd8GZDEhkkkGYNRsvIvtbp@2wFJy0nOPaAOwU8QNDA=&tp=" style="position: absolute; width: 880px; height: 1139px;"><canvas id="p12_vas" width="880px" height="1139px" style="z-index: 999; position: absolute;"></canvas><canvas id="p12_vas_0" width="880px" height="1139px" style="z-index: 996; position: absolute;"></canvas> <div style="position: absolute; width: 880px; height: 1139px;"></div> </div> </div>""" a = re.compile("src=\"img\?img=.*?tp=\"").findall(html) prefix_string = "https://document.ketangpai.com/" for index, i in enumerate(a): url = prefix_string + i[5: -1] print(index, url) with open(str(index) + ".png", 'wb') as f: req = urllib.request.urlopen(url) buf = req.read() f.write(buf)
这个代码会把图片下载到当前文件夹,来吧,展示