def reppro():
url="http:/xxx"
params={"serialNumber":15521101010}
header={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36","Content-Type": "application/x-www-form-urlencoded; charset=UTF-8","Host": "xxx"}
res=requests.post(url,data=params,headers=header)
ret='\"areaCode\":\"(\d+)\",\"areaName\":\"(.+?)\"'
resall=re.findall(ret,str(res.text))
for resone in resall:
texucity.objects.get_or_create(citynum=resone[0],
cityname=resone[1]
)
更多python编码关注