Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to check express delivery with Python

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to use Python to check express delivery, the content is concise and easy to understand, it can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

The above sentence is a famous saying of the Python community, which translates as "Life is too short, I use Python". I have never come across a programming language that is so clean and brief, and if you have a Virgo plot, you will fall in love with Python. The following is to complete the express query function with 10 lines of code.

Library: request and json, call express 100-check express delivery, send express delivery, send express 100 API.

Effect display

Implementation code

"

Author: Ah Guang

Data: 2018-10-21

"

Import json,requests

Def searchPackage ():

# enter the waybill number and note that it can only be found by express delivery on the way!

PackageNum = input ('Please enter waybill number:')

Url1 = 'http://www.kuaidi100.com/autonumber/autoComNum?resultv2=1&text=' + packageNum

# use url1 to query the courier company corresponding to the shipping order number, such as Zhongtong. Return: zhongtong.

# print (url1)

CompanyName = json.loads (requests.get (url1) .text) ['auto'] [0] [' comCode']

# print (requests.get (url1) .text)

# print (companyName)

# in the use of url2 query and waybill number, express company to query express details, the result is a json file, saved in resultdict with dict.

Url2 = 'http://www.kuaidi100.com/query?type=' + companyName +' & postid=' + packageNum

Print ('time ↓ and tracking progress ↓\ n')

For item in json.loads (requests.get (url2) .text) ['data']:

Print (item ['time'], item [' context'])

SearchPackage () # call query function

The above content is how to use Python to check express delivery. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report