作为一个爬虫爱好者,看到好东西就是想爬爬。
you-get 代码阅读
我吧原本的分工明确的代码给小作坊化了 ~
def make_xml_url(self,response):
# response是目标网页的text内容
# 假设目标网页是:https://www.bilibili.com/video/av16806353/?spm_id_from=333.334.chief_recommend.16,那么response就是这个网页的内容
cid = re.findall(r'cid=(\d+)', response.text)[0]
aid = re.findall(r'aid=(\d+)', response.text)[0]
ts = int(time.time())
# quality是画质的意思?为了简化函数,默认是mp4,mp4的代表值是1
# 其他的是 fmt2qlt = dict(hdflv=4, flv=3, hdmp4=2, mp4=1)
params_str = 'cid={}&player=1&quality={}&ts={}'.format(cid, 1, ts)
sign = hashlib.md5(params_str + self.SEC1).hexdigest()
# SEC1 = '1c15888dc316e05a15fdd0a02ed6584f'
# 这个SEC1是必要的参数,怎么来的我还在测试
params =