最近快递停发的比较多,发现快递100里面可以查询是否停运,于是抓包改成的了Python代码。
快递包括:三通一达 京东德邦,顺丰邮政
本代码不需要登录 ,自行修改代码中自己的地址。返回结果是拼音懒得替换了。
有人https报错,试试http
import requests requests.packages.urllib3.disable_warnings() url = 'https://p.kuaidi100.com/apicenter/order.do?method=expressStopInquiries' #url = 'http://p.kuaidi100.com/apicenter/order.do?method=expressStopInquiries' header = {'Host': 'p.kuaidi100.com', 'Connection': 'keep-alive', 'xweb_xhr': '1', 'user-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 MicroMessenger/7.0.4.501 NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF', 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': '*/*', 'Sec-Fetch-Site': 'cross-site', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Dest': 'empty', 'Referer': 'https://servicewechat.com/wx6885acbedba59c14/683/page-frame.html', 'Accept-Language': 'en-us,en', 'Accept-Encoding': 'gzip, deflate', 'Content-Length': '476'} data = {'platform': 'WWW', 'toProvince': '省份', 'toCity': '市', 'toArea': '县区', 'toAddress': '具体地址(小区)'} res = requests.request(method = 'POST', url = url, headers = header, data = data, verify = False) res=res.json() kuaidi=res['data']['toReachable'] for i in kuaidi: if i['reachable']==1: print(i['expressCode']+':已经开通')