curl查看:
curl http://www.kuaidi100.com/query?type=yuantong&postid=11111111111
#!/usr/bin/python
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
from urllib.request import Request,urlopen
from urllib.parse import quote
import json
import openpyxl
def get_data(search_url):
requests = Request(search_url)
# requests.add_header('Cookie',cookie)
response = urlopen(requests)
html = BeautifulSoup(response, 'html.parser', from_encoding='utf-8')
# print(html)
return html
def handle_data(html):
# get all text from html
rawdata = html.get_text()
print(rawdata)
json1 = json.loads(rawdata)
print(json1)
json2 = json1['data']
print(json2