-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcxkdurllib.py
More file actions
34 lines (27 loc) · 751 Bytes
/
cxkdurllib.py
File metadata and controls
34 lines (27 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import urllib2
import json
def detect_com(postid):
r = urllib2.urlopen('http://www.kuaidi100.com/autonumber/autoComNum?text='+postid)
h = r.read()
#j = json.dumps(h)
#k = json.loads(j)
k = eval(h)
kuaiditpye = k["auto"][0]['comCode']
#print kuaiditpye
return kuaiditpye
def cxkd(postid):
kuaiditype = detect_com(postid)
r = urllib2.urlopen('http://www.kuaidi100.com/query?type='+kuaiditype+'&postid='+postid)
h = r.read()
# print(r.json())
#j = json.dumps(h)
j = eval(h)
# print(j)
# print(j.keys())
# print(j['data'])
outcome = ''
for c in j['data']:
outcome = outcome + c['time']+' '+c['context']+'\n'
return outcome
#a = cxkd('280472503105')
#print a