Last active
October 18, 2017 02:11
-
-
Save eatradish/fe98ec0138dea964fa216ef87463e800 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
def get(kid): | |
comCode_url = 'https://www.kuaidi100.com/autonumber/autoComNum?text=' + kid | |
headers = {'Origin': "https://www.kuaidi100.com", 'Accept-Encoding': "gzip, deflate, br", 'Accept-Language': "en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4,ja;q=0.2,zh-TW;q=0.2,uz;q=0.2,vi;q=0.2", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"} | |
c_r = requests.post(comCode_url, headers = headers) | |
c_r = json.loads(c_r.text) | |
comCode = c_r['auto'][0]['comCode'] | |
get_url = 'https://www.kuaidi100.com/query?type=' + comCode + '&postid=' + kid + '&id=1&valicode=&temp=0.21830105590577142' | |
g_r = requests.post(get_url, headers = headers) | |
g_r = json.loads(g_r.text) | |
msgs = [] | |
for i in g_r['data']: | |
msgs.append('%(time)s %(context)s' % i) | |
pass | |
msg = '\n'.join(msgs) | |
print(msg) | |
def main(): | |
kid = 'ID‘ | |
get(kid) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment