Open MYF12 opened 3 years ago
这个功能已经失效了,现在不支持数字id转换用户id了
我找到了更好的方法了,通过长连接去获取就行了: def get_uid(self, d_url, headers_web): print(d_url) print(headers_web) r = requests.head(d_url, headers=headers_web, verify=False) long_url =r.headers.get('location') print(long_url)
url_list = re.split('[/?]', long_url)
uid = url_list[5]
print("uid 为:%s"%uid)
# 写入user_id到文件中
with open('../kuaishou/preset', 'w') as f:
f.write(uid)
我是通过直接输入短连接,然后获取原长连接,再从长连接获取到用户id写入到preset文件里面。不过我没有一次性爬取多个用户的
我是通过直接输入短连接,然后获取原长连接,再从长连接获取到用户id写入到preset文件里面。不过我没有一次性爬取多个用户的
你能提供你的代码吗? 作者这库已经失效了,我不想爬直播数据,想爬短视频数据
我找到了更好的方法了,通过长连接去获取就行了: def get_uid(self, d_url, headers_web): print(d_url) print(headers_web) r = requests.head(d_url, headers=headers_web, verify=False) long_url =r.headers.get('location') print(long_url) # 获取用户账户id url_list = re.split('[/?]', long_url) uid = url_list[5] print("uid 为:%s"%uid) # 写入user_id到文件中 with open('../kuaishou/preset', 'w') as f: f.write(uid)
请问传入的d_url和headers_web参数分别代表什么呢?在__switch_id方法里面调用吗?
现在已经找不到这个请求方式了 请求方式: payload = {"operationName": "SearchOverviewQuery","variables": {"keyword": uid, "ussid": None}, "query": "query SearchOverviewQuery($keyword: String, $ussid: String) {\n pcSearchOverview(keyword: $keyword, ussid: $ussid) {\n list {\n ... on SearchCategoryList {\n type\n list {\n categoryId\n categoryAbbr\n title\n src\n typename\n }\n typename\n }\n ... on SearchUserList {\n type\n ussid\n list {\n id\n name\n living\n avatar\n sex\n description\n counts {\n fan\n follow\n photo\n typename\n }\n typename\n }\n typename\n }\n ... on SearchLivestreamList {\n type\n lssid\n list {\n user {\n id\n avatar\n name\n typename\n }\n poster\n coverUrl\n caption\n id\n playUrls {\n quality\n url\n typename\n }\n quality\n gameInfo {\n category\n name\n pubgSurvival\n type\n kingHero\n typename\n }\n hasRedPack\n liveGuess\n expTag\n typename\n }\n typename\n }\n typename\n }\n typename\n }\n}\n"} print("__switch_id--payload:%s" % payload) print("switch_id--DATA_URL:%s" % DATA_URL) res = requests.post(DATA_URL, headers='headers_web', json=payload, verify=False) print(res.text) dt = json.loads(res.content.decode(encoding='utf-8', errors='strict'))['data']