@@ -15,7 +15,7 @@ def __init__(self, dirname, keyword):
15
15
'Accept' : '*/*' ,
16
16
'Accept-Encoding' : 'gzip, deflate, br' ,
17
17
'Accept-Language' : 'zh-CN,zh;q=0.9' ,
18
- 'Referer' : 'https://search.bilibili.com/all?keyword=%s' % parse .quote ('猫' )}
18
+ 'Referer' : 'https://search.bilibili.com/all?keyword=%s' % parse .quote (keyword )}
19
19
20
20
self .search_headers = {'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36' ,
21
21
'Accept-Language' : 'zh-CN,zh;q=0.9' ,
@@ -76,7 +76,7 @@ def search_video(self, search_url):
76
76
"""
77
77
req = self .sess .get (url = search_url , headers = self .search_headers , verify = False )
78
78
html = json .loads (req .text )
79
- videos = html ['result' ]
79
+ videos = html ["data" ][ 'result' ]
80
80
titles = []
81
81
arcurls = []
82
82
for video in videos :
@@ -159,7 +159,7 @@ def search_videos(self, keyword, pages):
159
159
if self .dir not in os .listdir ():
160
160
os .mkdir (self .dir )
161
161
for page in range (1 , pages + 1 ):
162
- search_url = 'https://search .bilibili.com/api/ search? search_type=video&keyword={}&order=totalrank&duration=1&tids=0 &page={}' .format (keyword , page )
162
+ search_url = 'https://api .bilibili.com/x/web-interface/ search/type?jsonp=jsonp& search_type=video&keyword={}&page={}' .format (keyword , page )
163
163
titles , arcurls = self .search_video (search_url )
164
164
for index , arcurl in enumerate (arcurls ):
165
165
title = titles [index ]
0 commit comments