import json
import requests
headers = {
'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36',
'referer':'https://www.douyin.com/channel/300203?modal_id=7370895688999111972',
'cookie':''
}
# cursor=0
while True:
# print(cursor)
url = 'https://www.douyin.com/aweme/v1/web/comment/list/?device_platform=webapp&aid=6383&channel=channel_pc_web&aweme_id=7370895688999111972&cursor=20&count=20&item_type=0&insert_ids=&whale_cut_token=&cut_version=1&rcFT=&update_version_code=170400&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1536&screen_height=864&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=127.0.0.0&browser_online=true&engine_name=Blink&engine_version=127.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=50&webid=7402234732509021711&verifyFp=verify_lzqzv2wr_4331ca96_569d_ee6a_4a6e_03697fa48a19&fp=verify_lzqzv2wr_4331ca96_569d_ee6a_4a6e_03697fa48a19&msToken=NZG2sEH89Nb1nLAkTognx03HedQXJTanV5rTTmWPdKtqY7Q1d_L8Jc6OD8h-nfT_bh5oNehCMeahZIn_hTilL24s8PJMT1ZYpGGAkeFMtr44-pHHwqe2grjZI6AUVjI%3D&a_bogus=QvWh%2F5zkdkgi6DyX5WcLfY3q6-F3YQtC0trEMD2fhd3rt639HMPA9exLHX4vMXSjN4%2FkIb6jy4htYrBMicIjA3v6HSRKl2Ck-g00t-P2so0j5ZhjCfuDrURF-vzWt-Bd-Jd3iQ4hy7dbFuRplnAJ5k1cthMea4R%3D'
response = requests.get(url,headers=headers)
context = json.loads(response.text)
for comment_list in context['comments']:
# print(comment_list)
com_text = comment_list['text']
com_addr = comment_list['ip_label']
com_user = comment_list['user']['nickname']
com_repl = comment_list['reply_comment_total']
print(f'{com_addr}【{com_user}】说:"{com_text}"有{com_repl}回复:')
if com_repl:
recom_id = comment_list['cid']
com_id = comment_list['aweme_id']
while True:
replyurl ='https://www.douyin.com/aweme/v1/web/comment/list/reply/?device_platform=webapp&aid=6383&channel=channel_pc_web&item_id=7370895688999111972&comment_id=7371293072783704868&cut_version=1&cursor=0&count=3&item_type=0&update_version_code=170400&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1536&screen_height=864&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=127.0.0.0&browser_online=true&engine_name=Blink&engine_version=127.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=50&webid=7402234732509021711&verifyFp=verify_lzqzv2wr_4331ca96_569d_ee6a_4a6e_03697fa48a19&fp=verify_lzqzv2wr_4331ca96_569d_ee6a_4a6e_03697fa48a19&msToken=wyrRvp4Xh7HpCdYO5HF9EmJFlSpLtlgIEGQN37Ub7VjuKyM6stBhastl9zeH6tXcOII6OJ4ve_CRIqfRrfl1m-OJOWkuTwRof_RQRorbzM4u4FIEFPRaq__NGJfMNZ0%3D&a_bogus=mX8qQ5uXdkgivf6X5WcLfY3q61e3YQto0trEMD2fwn3ro639HMPH9exLH6Gv61RjN4%2FkIb6jy4htYrBMicIjA3v6HSRKl2Ck-g00t-P2so0j5ZhjCfuDrURF-vzWt-Bd-Jd3iQ4hy7dbFuRplnAJ5k1cthMeaUg%3D'
response1 = requests.get(replyurl,headers=headers)
context1 = json.loads(response1.text)
# print(context)
has_more = context1['has_more']
count = 0
for recomment_list in context1['comments']:
recom_text = recomment_list['text']
recom_user = recomment_list['user']['nickname']
recom_addr = recomment_list['ip_label']
recom_tot = recomment_list['comment_reply_total']
if count < recom_tot:
print(f'\t{count}{recom_addr}【{recom_user}】回复说:"re{recom_text}"')
count +=1
else:
break
评论如何批量获取,如何获得回复评论,大家相互交流
青龙摄影2024-08-13 15:37
相关推荐
封步宇AIGC17 分钟前
量化交易系统开发-实时行情自动化交易-Okex K线数据封步宇AIGC19 分钟前
量化交易系统开发-实时行情自动化交易-Okex交易数据小爬虫程序猿21 分钟前
如何利用Python解析API返回的数据结构?波点兔23 分钟前
【部署glm4】属性找不到、参数错误问题解决(思路:修改模型包版本)一点媛艺3 小时前
Kotlin函数由易到难魔道不误砍柴功4 小时前
Java 中如何巧妙应用 Function 让方法复用性更强_.Switch5 小时前
高级Python自动化运维:容器安全与网络策略的深度解析测开小菜鸟6 小时前
使用python向钉钉群聊发送消息萧鼎7 小时前
Python并发编程库:Asyncio的异步编程实战学地理的小胖砸7 小时前
【一些关于Python的信息和帮助】