Iv. Design and Implementation of 12306 ticket snatching Software Based on HTTPS protocol-horizontal DNS concurrent query and sharing, https12306

Source: Internet
Author: User

Iv. Design and Implementation of 12306 ticket snatching Software Based on HTTPS protocol-horizontal DNS concurrent query and sharing, https12306

I. Design and Implementation of 12306 ticket snatching Software Based on HTTPS protocol -- Implementation Effect
2. Design and Implementation of 12306 ticket snatching Software Based on HTTPS protocol-related interfaces and data formats

Iii. Design and Implementation of the 12306 ticket snatching software based on the HTTPS protocol-vertical query effect sharing

 

 

Ah, it's a new year, and the comrades have to grab the ticket and go home again. It's really fast to sell this ticket. In an instant, there will be no tickets. It's hard to get one ticket!

 

In the past two days, I had nothing to worry about. I just had to grab the ticket for the Spring Festival. I opened the original ticket grabbing software and tried again. I found that I could not check the ticket, so I changed it again. In fact, it was changed twice,First, it allows the original program to be used (to adapt to the new interface), but with the addition of horizontal DNS concurrent queries. Let's talk about it in sequence.

 

I. Interface change

In fact, this 12306 has not been significantly changed. Only a few interfaces have been changed.

1.1 login verification code

This is just the suffix of an action (. do). It's okay if you don't change it, but if something goes wrong in the future, you can change it.
Https://kyfw.12306.cn/otn/passcodeNew/getPassCodeNew Interface
Parameter: Same as before.

1.2 query tickets

Interface: https://kyfw.12306.cn/otn/leftTicket/queryT (followed by a T)
The parameter is not changed.

1.3 log query interface

In fact, this interface is newly added, that is, to execute a log query interface before the query ticket is executed. I tried it and found that this interface does not work, however, the ticket query interface will be slower, so I added it at the end. It is very simple, just send the next request.
Https://kyfw.12306.cn/otn/leftTicket/log Interface
Method: GET
Parameters: the parameters are the same as those for querying tickets.
Return Value: No worries.

1.4 contact Acquisition Interface

This interface has not been significantly changed. If you have fewer contacts, you don't have to worry about it. Because my contacts have two pages, but only the contacts on the first page can be obtained according to the interface provided previously, the contacts on the second page cannot be obtained normally, so the change is as follows:
Https://kyfw.12306.cn/otn/passengers/query Interface
Method: GET or POST
Parameter: pageIndex (page number)
PageSize (How many records per page)
Return Value: json format. It can be parsed slightly. The field name is not changed.

 

Ii. Horizontal DNS concurrent Query

In fact, the biggest change is to add a horizontal DNS query. Because 12306 is a globally accessible website that requires high concurrency and other functions, multiple servers are provided in various regions through DNS resolution, users in different regions access the server closest to the local server for resolution. In this way, 12306 is used to break down high-concurrency requests from different regions. However, in this case, another problem is that users in different regions can grab the same train ticket at the same time, but the page data may be different. Some users can see the remaining tickets, some cannot see it because they are not accessing the same 12306 server and different caches.


The horizontal DNS query function is simply to list the remaining information about the same ticket of 12306 servers in different regions.

Displays the same ticket information for 12306 servers around the world at the same time (This is just a demonstration. If you want to see the difference, you can see that different servers will display different results during the time when you place the ticket.).

In fact, the implementation is also very simple. First, we use the DNS query tool to query the IP addresses of servers in different regions corresponding to the 12306 website (kyf201712306.cn), and then each region requests the same number of trains, then list it in the table, which is simple.


This function is very practical and can indirectly reflect the response speed of servers in different regions. Finally, if there is a pass in the vehicle count information for a certain region, you only need to modify the current DNS of the program, so that the kyf201712306.cn domain name corresponds to that IP address, and then you can access that IP address to book tickets for a remote server.


Finally, when I performed a horizontal DNS query in my experiment, I found thatIf you select a remote server to book tickets, you will find that you need to log on to the remote server again to book tickets.(It can be said that 12306 of application servers across the country do not share sessions ).

 


 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.