码迷,mamicode.com
首页 > 其他好文 > 详细

Fixing getting video from bilibili.com by you-get

时间:2020-02-19 06:00:06      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:lib   row   obj   class   ade   common   pytho   init   res   

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.

Fixing getting video from bilibili.com by you-get

标签:lib   row   obj   class   ade   common   pytho   init   res   

原文地址:https://blog.51cto.com/cfy10/2472112

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!