In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
How to use python express query system, I believe that many inexperienced people do not know what to do about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Introduction
With the widespread popularity of online shopping, now most young people like the way of online shopping.
Many things are good and cheap, can not go out of the house can also meet your purchase needs!
Especially when the Mid-Autumn Festival is coming, those who can't go home for a short holiday also want to bring some Mid-Autumn Festival gifts to their families.
Isn't that right? Catch up with the Mid-Autumn Festival, there have been several times when sending things to home before, the logistics information has not been updated, it is not clear where the things are, ask the seller: sometimes there is no update above, but I will call you to pick up the express delivery when I get to your downstairs.
Sure enough, emmmmmm, "excuse me!" I don't know if you've met?
Later, the editor found logistics information 23333 in a special national express website. I feel that this is quite practical, at least the express delivery is not lost!
Today, Muzi will take you to write an exclusive express logistics query system with an interface ~ you no longer have to worry about your own express suddenly disappearing!
Text
Environmental installation:
Install the package-Python3, Pycharm2021, module-requests, pyqt5.
Pip install requestspip install pyqt5 # of course the image source can be installed faster, so please contact me directly for environmental problems.
(1) first of all, import the information of all express delivery companies, which is the data from the previous climb, taking the express 100 as an example.
Companies = pickle.load (open ('companies.pkl',' rb'))
(2) use express 100 to inquire about express delivery.
Def getExpressInfo (number): url = 'http://www.kuaidi100.com/autonumber/autoComNum?resultv2=1&text=%s'% number headers = {' User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64) X64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36', 'Host':' www.kuaidi100.com'} infos = [] for each in requests.get (url Headers=headers) .json () ['auto']: company_name = each [' comCode'] url = 'http://www.kuaidi100.com/query?type=%s&postid=%s'% (company_name, number) temps = requests.get (url) Headers=headers) .json () ['data'] info =' Company:% s\ n'% py2hz (company_name) for idx Each in enumerate (temps): if idx = 0: info + ='-'* 60 +'\ ntime:\ n' + each ['time'] +'\ nProgress:\ n' + each ['context'] +'\ n' +'-'* 60 +'\ n' else: Info + = 'time:\ n' + each [' time'] +'\ nProgress:\ n' + each ['context'] +'\ n' +'-'* 60 +'\ n' if not temps: info + ='-'* 60 +'\ n' + 'order number does not exist or has expired\ n' +' -'* 60 +'\ N 'infos.append (info) return infos
(3) make the interface of the express query system.
Class ExpressGUI (QWidget): def _ _ init__ (self, parent=None): super (ExpressGUI Self). _ init__ (parent) self.setWindowTitle ('express inquiry system') self.label1 = QLabel ('express order number:') self.line_edit = QLineEdit () self.label2 = QLabel ('query result:') self.text = QTextEdit () self.button = QPushButton () self.button.setText ('query') self.grid = QGridLayout () self.grid.setSpacing (12) self.grid.addWidget (self.label1 1,0) self.grid.addWidget (self.line_edit, 1,1,1,39) self.grid.addWidget (self.button, 1,40) self.grid.addWidget (self.label2, 2,0) self.grid.addWidget (self.text, 2,1,1,40) self.setLayout (self.grid) self.resize Self.button.clicked.connect (self.inquiry) def inquiry (self): number = self.line_edit.text () try: infos = getExpressInfo (number) if not infos: infos = ['-'* 60 +'\ n' + 'order number does not exist or has expired\ n' -' * 60 +'\ n'] except: infos = ['-'* 60 +'\ n' + 'express order number is incorrect Please re-enter.\ n' +'-'* 60 +'\ n'] self.text.setText ('\ n\ n\ n'.join (infos) [:-1])
The effect is as follows:
Attached source code:''Function: express inquiry system source base: # 959755565#'''import sysimport pickleimport requestsfrom PyQt5.QtWidgets import *' import all express company information 'companies = pickle.load (open (' companies.pkl') 'rb'))' 'turn the pinyin of the express delivery company into Chinese characters' def py2hz (py): return companies.get (py) 'def getExpressInfo (number): url =' http://www.kuaidi100.com/autonumber/autoComNum?resultv2=1&text=%s'% number headers = {'User-Agent' ':' Mozilla/5.0 (Windows NT 10.0 Win64 X64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36', 'Host':' www.kuaidi100.com'} infos = [] for each in requests.get (url Headers=headers) .json () ['auto']: company_name = each [' comCode'] url = 'http://www.kuaidi100.com/query?type=%s&postid=%s'% (company_name, number) temps = requests.get (url) Headers=headers) .json () ['data'] info =' Company:% s\ n'% py2hz (company_name) for idx Each in enumerate (temps): if idx = 0: info + ='-'* 60 +'\ ntime:\ n' + each ['time'] +'\ nProgress:\ n' + each ['context'] +'\ n' +'-'* 60 +'\ n' else: Info + = 'time:\ n' + each [' time'] +'\ nProgress:\ n' + each ['context'] +'\ n' +'-'* 60 +'\ n' if not temps: info + ='-'* 60 +'\ n' + 'order number does not exist or has expired\ n' +' -'* 60 +'\ N 'infos.append (info) return infos''to make a simple GUI'''class ExpressGUI (QWidget): def _ init__ (self) Parent=None): super (ExpressGUI Self). _ init__ (parent) self.setWindowTitle ('express inquiry system') self.label1 = QLabel ('express order number:') self.line_edit = QLineEdit () self.label2 = QLabel ('query result:') self.text = QTextEdit () self.button = QPushButton () self.button.setText ('query') self.grid = QGridLayout () self.grid.setSpacing (12) self.grid.addWidget (self.label1 1,0) self.grid.addWidget (self.line_edit, 1,1,1,39) self.grid.addWidget (self.button, 1,40) self.grid.addWidget (self.label2, 2,0) self.grid.addWidget (self.text, 2,1,1,40) self.setLayout (self.grid) self.resize Self.button.clicked.connect (self.inquiry) def inquiry (self): number = self.line_edit.text () try: infos = getExpressInfo (number) if not infos: infos = ['-'* 60 +'\ n' + 'order number does not exist or has expired\ n' -' * 60 +'\ n'] except: infos = ['-'* 60 +'\ n' + 'express order number is incorrect Please re-enter.\ n'+'* 60 +'\ n'] self.text.setText ('\ n\ n\ n'.join (infos) [:-1])''run'''if _ _ name__ = =' _ _ main__': app = QApplication (sys.argv) gui = ExpressGUI () gui.show () sys.exit (app.exec_ ()) read the above Do you know how to use the python express query system? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.