add UA fix some time statuscode=403

This commit is contained in:
hcwhan 2017-10-30 20:18:29 +08:00 committed by GitHub
parent ac6b97618f
commit 5db51c9478
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,8 +39,11 @@ def douyutv_download(url, output_dir = '.', merge = True, info_only = False, **k
if 'v.douyu.com/show/' in url:
douyutv_video_download(url, output_dir=output_dir, merge=merge, info_only=info_only, **kwargs)
return
html = get_content(url)
headers = {
'user-agent': 'Mozilla/5.0 (iPad; CPU OS 8_1_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B466 Safari/600.1.4'
}
html = get_content(url, headers)
room_id_patt = r'"room_id"\s*:\s*(\d+),'
room_id = match1(html, room_id_patt)
if room_id == "0":