Fixing getting video from bilibili.com by you-get

After the spring festival, I found that the bilibili video could not download normally.
The ERROR log:
[DEBUG] HTTP Error with code403
......
File "D:\Python36\Lib\json__init.py", line 348, in loads
'not {!r}'.format(s.
class.name__))
TypeError: the JSON object must be str, bytes or bytearray, not 'NoneType'

Log indicates that a website request was rejected.
When I use brower to play the video, it is normally.

Solution:
Adding the fake header info.
{
req.add_header('User-Agent', "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:10.0) Gecko/20100101 Firefox/10.0 ")
}
in common.py (line 431) after
{
req = request.Request(url, headers=headers)
}

Result:
Try again, download the video normally.

猜你喜欢

转载自blog.51cto.com/cfy10/2472112