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标签:comment,批量,recom,list,如何,version,评论,com,browser From: https://blog.csdn.net/lfsysc/article/details/141161571