Paython 模拟抓取视频

Paython 模拟抓取视频

提示:
例如: Python 机器学习入门获取视频

import requests, os, sys
from lxml import etree
from you_get import common as you_get

key = "绝地求生"

url = f'''网址'''

headers = {
	如果没有获取相关信息,需要填写headers相关阐述
}
response = requests.get(url, headers=headers)
html = response.text
html = etree.HTML(html)
video_list = html.xpath('//相关路径')
path = "//下载存放绝对路径"

for video in video_list[:1]:
    video_url = video.xpath('./@href')[0]
    video_url = 'https:' + video_url
    print(video_url)
    video_title = video.xpath('./h3/@title')[0]
    print(video_url, video_title)
    ##多种下载方法
    #sys.argv = ['you-get', '-o', path, video_url]
    #you_get.main()
    os.system(f' you-get  {video_url}  -o {path}')
    #sys.argv = ['you-get ', '-o', path, video_url]
    you_get.main()
    print(video_title, '下载成功')

总结

方法实操有效,感兴趣可以研究!

你可能感兴趣的:(python,网络爬虫)