记录一下自己学习python的小知识,从零开始
import requests
import json
from lxml import html
array = []
for key in array:
# url = 'https://movie.douban.com/' #需要爬数据的网址
url = 'https://hdgateway.zto.com/WayBill_GetDetail?billCode='+key
page = requests.Session().get(url)
tree = html.fromstring(page.text)
result = tree.xpath('//body') #获取需要的数据
res = result[0].xpath('string(.)').strip()
json_str = json.loads(res)
dict_str = str(json_str)
这个是获取中通最新快递信息的代码