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
相关推荐
m0_734949791 小时前
MySQL如何配置定时清理过期备份文件_find命令与保留周期策略m0_514520572 小时前
MySQL索引优化后性能没提升_通过EXPLAIN查看索引命中率H Journey2 小时前
Python 国内pip install 安装缓慢Polar__Star3 小时前
如何在 AWS Lambda 中正确使用临时凭证生成 S3 预签名 URLm0_743623923 小时前
React 自定义 Hook 的命名规范与调用规则详解FreakStudio4 小时前
无硬件学LVGL—定时器篇:基于Web模拟器+MicroPython速通GUI开发gCode Teacher 格码致知4 小时前
Python提高:pytest的简单案例-由Deepseek产生不要秃头的小孩5 小时前
力扣刷题——509. 斐波那契数科雷软件测试5 小时前
使用python+Midscene.js AI驱动打造企业级WEB自动化解决方案星越华夏5 小时前
python——三角函数用法