import requests from bs4 import BeautifulSoup import re url = 'https://ibaotu.com/shipin/7-0-0-0-3-1.html' resource = requests.get(url) html = resource.text soup = BeautifulSoup(html, 'xml') net_url = soup.find_all('video') video_url = [] for x in net_url: if x.get('src'): video_url.append('https:'+x.get('src')) # print(video_url) titles = re.findall(r'<span class="video-title">(.*?)</span>', html) for x,y in zip(titles, video_url): try: mp4_url = requests.get(y, timeout=10) except requests.exceptions.ConnectionError: print('出错啦') continue fn = open('F:\Python\PythonData/'+x+'.mp4', 'wb') fn.write(mp4_url.content) fn.close()
Python 超级简单的小视频爬虫工具
最新推荐文章于 2024-08-24 11:00:06 发布