@@ -127,20 +127,23 @@ def get_video_urls(self, user_id, type_flag='f'):
127
127
headers = {
128
128
'User-Agent' : 'Aweme/2.7.0 (iPhone; iOS 11.0; Scale/2.00)'
129
129
}
130
- req = requests .get ('https://api.amemv.com/aweme/v1/general/search/' , params = params , headers = headers )
131
- html = json .loads (req .text )
132
- uid = html ['user_list' ][0 ]['user_info' ]['uid' ]
133
- nickname = html ['user_list' ][0 ]['user_info' ]['nickname' ]
134
- unique_id = html ['user_list' ][0 ]['user_info' ]['unique_id' ]
135
- if unique_id != user_id :
136
- unique_id = html ['user_list' ][0 ]['user_info' ]['short_id' ]
137
- if unique_id != user_id :
138
- print ('用户ID可能输入错误或无法搜索到此用户ID' )
139
- sys .exit ()
130
+ #req = requests.get('https://api.amemv.com/aweme/v1/general/search/', params=params, headers=headers)
131
+ #html = json.loads(req.text)
132
+ #uid = html['user_list'][0]['user_info']['uid']
133
+ #nickname = html['user_list'][0]['user_info']['nickname']
134
+ #unique_id = html['user_list'][0]['user_info']['unique_id']
135
+ #if unique_id != user_id:
136
+ # unique_id = html['user_list'][0]['user_info']['short_id']
137
+ # if unique_id != user_id:
138
+ # print('用户ID可能输入错误或无法搜索到此用户ID')
139
+ # sys.exit()
140
+ uid = user_id
140
141
share_user_url = 'https://www.amemv.com/share/user/%s' % uid
141
142
share_user = requests .get (share_user_url , headers = self .headers )
142
143
_dytk_re = re .compile (r"dytk:\s*'(.+)'" )
143
144
dytk = _dytk_re .search (share_user .text ).group (1 )
145
+ _nickname_re = re .compile (r'<p class="nickname">(.+?)<\/p>' )
146
+ nickname = _nickname_re .search (share_user .text ).group (1 )
144
147
urllib .request .urlretrieve ('https://raw.githubusercontent.com/Jack-Cherish/python-spider/master/douyin/fuck-byted-acrawler.js' , 'fuck-byted-acrawler.js' )
145
148
try :
146
149
process = Popen (['node' , 'fuck-byted-acrawler.js' , str (uid )], stdout = PIPE , stderr = PIPE )
@@ -250,6 +253,7 @@ def run(self):
250
253
None
251
254
"""
252
255
self .hello ()
256
+ print ('搜索api需要登录,暂时使用UID下载\n 分享用户页面,用浏览器打开短链接,原始链接中/share/user/后的数字即是UID' )
253
257
user_id = input ('请输入ID (例如95006183):' )
254
258
user_id = user_id if user_id else '95006183'
255
259
watermark_flag = input ('是否下载带水印的视频 (0-否(默认), 1-是):' )
0 commit comments