包圖網素材視頻爬取


import requests
from lxml import etree

try:
page = 1
start_url = 'https://ibaotu.com/shipin/7-0-0-0-0-{}.html'

for page in range(1, 223):
url = start_url.format(page)
headers = {'UserAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:66.0) Gecko/20100101 Firefox/66.0'}

response = requests.get(url, headers=headers).text
sp = etree.HTML(response)
data_url = sp.xpath('//div[@class="video-play"]/video/@src')
data_title = sp.xpath('//span[@class="video-title"]/text()')

for sc_url,sc_title in zip(data_url,data_title):
html_url = 'https:'+sc_url
html_title = sc_title
# print(html_title,html_url)
content_ = requests.get(html_url,headers=headers)
with open('包圖網視頻素材/{}.mp4'.format(html_title),'wb') as f:
f.write(content_.content)
print("正在下載"+html_title)
print("已完成"+html_title+"下載")










except Exception as error:
print(error)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM