评论如何批量获取,如何获得回复评论,大家相互交流

复制代码
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
相关推荐
Dream_Snowar8 分钟前
速通Python 第三节
开发语言·python
蓝天星空1 小时前
Python调用open ai接口
人工智能·python
jasmine s2 小时前
Pandas
开发语言·python
郭wes代码2 小时前
Cmd命令大全(万字详细版)
python·算法·小程序
leaf_leaves_leaf2 小时前
win11用一条命令给anaconda环境安装GPU版本pytorch,并检查是否为GPU版本
人工智能·pytorch·python
夜雨飘零12 小时前
基于Pytorch实现的说话人日志(说话人分离)
人工智能·pytorch·python·声纹识别·说话人分离·说话人日志
404NooFound2 小时前
Python轻量级NoSQL数据库TinyDB
开发语言·python·nosql
天天要nx2 小时前
D102【python 接口自动化学习】- pytest进阶之fixture用法
python·pytest
minstbe2 小时前
AI开发:使用支持向量机(SVM)进行文本情感分析训练 - Python
人工智能·python·支持向量机
落魄实习生3 小时前
AI应用-本地模型实现AI生成PPT(简易版)
python·ai·vue·ppt