今日扒取某站成功,使用Jupyter notebook
import requests
res=requests.get("someSite/category_8")
from lxml import etree
res_xpath=etree.HTML(res.text)
import re
for li in res_xpath.xpath('//ul[@id="categoryList"]/li/div/a/@href'):
url='https://www.pearvideo.com/' + li
res=requests.get(url)
video=re.findall('srcUrl="(.*?)"',res.text,re.S)[0]
subpage=etree.HTML(res.text)
title=subpage.xpath('//div[@id="poster"]/img/@alt')[0]
response=requests.get(video)
with open( str(title).replace('?','_').replace(' ','').strip()+ '.mp4',mode='wb') as videoFile:
videoFile.write(response.content)
print("DownLoad 1 item")
print("everything done!")