In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to use python to grab tickets to go home, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
Before you know it, the annual Spring Festival travel season has begun. Do you want to grab the ticket home quickly? As a programmer, you must know these techniques.
In order to make it faster and more convenient for everyone to grab train tickets, a variety of ticket grabbing software is needed, most of which are paid for ticket grabbing mechanism.
As a programmer, how to use technical means to get a ticket home? Let's take a look at the ticket grabbing script written in Python.
Teach you hand-in-hand to use Python to grab tickets and go home for the Spring Festival
Environment introduction
Windows 8.1
Python3.6.1
Firefox plug-in geckodriver.exe
Operation steps
Introduce the desired module
Landing module
First, you need to choose the browser to use. Here, take firefox as an example, download: geckodriver.exe.
The mentioned stations.txt can look directly at this:
Station Information:
Https://kyfw.12306.cn/otn/resources/js/framework/station_name.js?station_version=1.9042
Just put geckodriver.exe in the python.exe sibling directory (if there is an error, put a file in the same directory as firefox.exe and add the environment variable)
Jump module
Start buying tickets
Here, it is to click on the scheduled operation. I am just here to give an example of a method, and I can also click until it succeeds (this can avoid the time difference between the countdown and the actual time of the website. But I don't know if 12306 has any restrictions on continuous fast access when grabbing tickets).
Summary
Areas that need to be replaced:
User name, password.
The value value of the starting place and destination can be modified by checking stations.txt.
Departure time.
Choose the xpath path of the train, the path does not need to change, change corresponding to the id.
Check the location of the user (if there is only one user, default: normalPassenger_0).
The selected seat category defaults to the cheapest category among the categories with tickets.
The rest are the same in the test, and no change is found. Before using it, you can test the code. The test is to comment out the code for submitting the order (there is a cancellation limit for issuing the order, which seems to be canceled only three times a day), and the network speed is normal during the test.
Some people say that the execution speed with the browser will be slow, and it is true that for scripts that can directly identify the CAPTCHA, it will be faster without the interface, but in fact, the time used is from the scheduled start to the end. Under the same network, the execution time of the code is faster than that of manual operation. Many partners often do not want to learn Python because they have no information or no guidance. So I specially prepared a large number of PDF books and video tutorials, all of which are given to you for free! Whether you have a zero foundation or a foundation, you can get your own corresponding learning gift package! Including Python software tools and 2019 latest getting started to hands-on tutorials, (http://nxw.so/3rsqX) copy to the browser to open!
In addition, time can be studied. When we have studied the time of a certain treasure before, the second kill time is a few seconds earlier than Beijing time. I feel that there is a small time difference across the country.
Complete script example
After reading the above, have you mastered how to use python to grab tickets and go home? 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.