爬取网络评论并且写到word文档里面

    科技2024-03-21  96

    #-*- codeing = utf-8 -*- #@Time : 2020/10/7 9:06 #@Author : dualseason #@File : catch_data.py #@Software : PyCharm import requests import json file = open('venv/text/comment_new3.doc','a') resp = requests.get('https://club.jd.com/comment/productPageComments.action?callback=fetchJSON_comment98&productId=100008348542&score=0&sortType=5&page=0&pageSize=10&isShadowSku=0&fold=1') resp = resp.text.replace('fetchJSON_comment98(','').replace(');','') json_data = json.loads(resp) comments = json_data['comments'] for item in comments: id = item['id'] guid = item['guid'] content = " " +item['content'] + '\n\n' file.write(content)
    Processed: 0.008, SQL: 8