How to write the code in python to save the crawled data from the following program into the csv file?

topic description

the program that saves the crawled data from this program into the csv file

sources of topics and their own ideas

self-written program ~

related codes

import urllib.request
import urllib.parse
import json
import re
import requests

class QueryPrice(object):
    def __init__(self, who, weight):
        self.who = int(who)
        self.weight = int(weight)
        self.url = "http://www.kuaidiwo.cn/freight/ajaxjg.php"

    def get_response(self):
        headers = {
            "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) Chrome/63.0.3239.26 QQBrowser/10.0.1125.400"
        }
        data = {
            "expid": self.who,
            "provinceid": 9, -sharpid
            "cityid": 155, -sharpid
            "toprovinceid": 1, -sharpid
            "tocityid": 41, -sharpod
            "weight": self.weight
        }

        html = requests.post(self.url, data, headers).text
        """
        data = urllib.parse.urlencode(data, encoding="utf-8")
        req = urllib.request.Request(self.url, data, headers)
        resp = resp.read().decode("utf-8")
        """

        return html

    def get_result(self):
        first = "-->  %dkg:"  %self.weight
        html = self.get_response()
        info = json.loads(html)
        if info["data"] and info["jg"]:
            result1 = first + "%s \t%s " % (info["jg"], info["data"][0]["name"])
            return result1
        else:
            result2 = first + "{0} \t id={1}".format(info["jg"], self.who)
            return str(result2)

if __name__ == "__main__":
    prices = []
    for i in range(1, 50):
        q = QueryPrice(i, 20)
        result = q.get_result()
        price = int(re.findall(r"(\d+)\s", result)[0])
        if price != 0:
            print(result)
            prices.append(price)
    print(": %s \n: %s" % (min(prices),max(prices)))

what result do you expect? What is the error message actually seen?

you can see the programs saved in csv and the generated csv files ~

Mar.30,2022

tt=s.get(url2,headers=header)
with open('123.csv','wb') as fx:
    fx.write(tt.content)

the data that climbs down is written directly.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb6f3e-483eb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb6f3e-483eb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?