爬取下载b站视频【附源码】,话不多说,说干就干。
下载仓库
git@github.com:inspurer/PythonSpider.git
或者直接下载:https://github.com/inspurer/PythonSpider/tree/master/bilibili
替换
随便打开一个b站的界面,比如
将url复制到代码中去,运行代码,稍等一会儿,上述图中的视频就被下载下来了。
完整代码奉上!import requests
import re
import json
from contextlib import closing
from pyquery import PyQuery as pq
from requests import RequestException
class bilibili():
def __init__(self):
self.getHtmlHeaders={
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-CN,zh;q =