一位路过的垃圾技术宅给各位吧友一点礼物>>
只是偶然间看视频发现了“视频不见了”页面下面的漫画>>
百度N久之后,并没有在网上其他地方找到漫画集>>
所以只是突然间的兴致,想写个爬虫,把漫画爬下来>>
(只是偶然间路过此地,现在技术略有所得,所以想给各位吧友分享一下收获)
这是python爬虫的过程
这是python爬虫源码,python3.7,用到了requests,pyppeteer和simplified-scrapy库。一下是源码文本版>
>>>
from simplified_html.request_render import RequestRender
from simplified_scrapy.simplified_doc import SimplifiedDoc
import requests
str0 = ''
def callback(html,url,data):
doc = SimplifiedDoc()
div = doc.getElementByClass('img-box',html)
global str0
try:
str0 = (doc.listImg(div.innerHtml,url))[0]['url']
except:
pass
#print(type(str0))
def down(str0):
re = requests.get(str0)
with open('%s'%str0[-29:-21] + '%s'%str0[-20:-6],'wb') as f:
f.write(re.content)
for i in range(0,999):
req = RequestRender({ 'executablePath': r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'})
try:
req.get('https://www.bilibili.com/video/av76509567/',callback)
print(str0)
down(str0)
except:
i = i - 1
req.close()
>>>
自此,无意叨扰,愿各位能有所获。
只是偶然间看视频发现了“视频不见了”页面下面的漫画>>
百度N久之后,并没有在网上其他地方找到漫画集>>
所以只是突然间的兴致,想写个爬虫,把漫画爬下来>>
(只是偶然间路过此地,现在技术略有所得,所以想给各位吧友分享一下收获)
这是python爬虫的过程
这是python爬虫源码,python3.7,用到了requests,pyppeteer和simplified-scrapy库。一下是源码文本版>
>>>
from simplified_html.request_render import RequestRender
from simplified_scrapy.simplified_doc import SimplifiedDoc
import requests
str0 = ''
def callback(html,url,data):
doc = SimplifiedDoc()
div = doc.getElementByClass('img-box',html)
global str0
try:
str0 = (doc.listImg(div.innerHtml,url))[0]['url']
except:
pass
#print(type(str0))
def down(str0):
re = requests.get(str0)
with open('%s'%str0[-29:-21] + '%s'%str0[-20:-6],'wb') as f:
f.write(re.content)
for i in range(0,999):
req = RequestRender({ 'executablePath': r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'})
try:
req.get('https://www.bilibili.com/video/av76509567/',callback)
print(str0)
down(str0)
except:
i = i - 1
req.close()
>>>
自此,无意叨扰,愿各位能有所获。