preface

It's time to go home and grab tickets for the annual Spring Festival



Although just New Year's day holiday home a trip



But now to go home for the New Year to prepare tickets 😂

Copy the code

Set a date for your return

Asked around the office

They all said they would go back on February 5th, that is, five days ahead of schedule

I'll be back on the 5th, too

Copy the code

Confirm the train and start scrambling for tickets


I bought my tickets in this way and started buying tickets as soon as they were released

The result was predictable and not snatched

After all, it's not surprising that there are millions of people who can't get it



Copy the code

Why can’t I get it

  • You can’t get a red envelope

  • You can’t get it if you buy Maotai

  • I can’t get a ticket

In this age of too many graduates and too few graduates



In the normal way

The odds of getting what you want are slim



Because there's no money, no resources, no background



How do you get tickets under those circumstances



As a programmer

Take advantage of software tools, of course

Copy the code

Rob ticket tool

This article first introduces the ticket snatching tool

The following articles will introduce the tools for grabbing red envelopes and Maotai

Copy the code

Python source code

https://gitee.com/pingfanrenbiji/ticket-12306



If python3 is not available, install it yourself

Copy the code

Install dependencies

  • Open through the PyCharm compiler and follow the dependencies

or

  • Follow the dependency by command
pip3 install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple 

Copy the code

The configuration file

ticket-12306/TickerConfig.py



Configuration items to be configured:



Departure date

Pre-sale release time

Buy trains

Trigger the city

Reach the city

Seat type

Name of passenger



12306 Login account (TK, RAIL_DEVICEID)



Copy the code

Obtain the 12306 login account

Open 12306 ticket website, right click to check, click login


  • tk

  • RAIL_DEVICEID

Note: Get the value of RAIL_DEVICEID

Join the CDN

python3 run.py c

Copy the code

Started to vote

Open another window to grab tickets



python3 run.py r

Copy the code

So we're fighting for tickets all the time

It is suggested to open 3 window to grab tickets

Open too much worry will be 12306 IP



If someone else cancels the ticket, you can grab it

If you grab a ticket, you can find it in 12306- Personal Center - Train ticket Order - Outstanding Order

I see this unpaid order



Just pay and you get the ticket

Copy the code

Parameter Description

This is also explained in the configuration file

Brush ticket mode

  • Brush ticket

  • Waiting list + ticket brushing



First presale presale after the end of the ticket no one can return the ticket to pick up



Standby means no tickets available through 12306 platform to help grab tickets

The success of waiting is the success of snatching tickets





If the software is successful, it will stop snatching tickets and send an email notification

But it won't affect you to continue to pick up



If you pick it up at this time, you can also pay successfully

Copy the code

The premise of a waiting ticket

If it's a standby ticket

Users who need to pass the identity verification test and active members of "Free Rail" can submit waiting requests

Please complete the identity verification on railway 12306APP according to the operation instructions

Copy the code

Notice of successful ticket snatching

Email notification


Notice on wechat official account


  • Using document
http://sc.ftqq.com/3.version

Copy the code
  • Go to Github to get Secret
http://sc.ftqq.com/?c=code

Copy the code
Figure 1
  • Binding WeChat

  • Click the Send tool in Figure 1 to send
You can get notifications on wechat

Copy the code

Order model

  • Open to booking
Refresh the hour

Refresh interval 0.1-0.5s and then check the time



For example, at 12 o 'clock, the script will check in at 12.00 sharp and refresh the order

Copy the code
  • The rule
The refresh interval is 0.5-3 seconds, the time interval is long, it is not easy to seal IP

Copy the code

The agent

  • role
Prevents the IP address of request 12306 from being blocked



For example, the current LAN egress IP address is IP1. The proxy IP address is IP2



If the proxy is enabled



Ip1 is forwarded to IP2, and IP2 accesses 12306



If the proxy pool is enabled



Then IP1 forwards to any IP address in the proxy pool and accesses 12306

Copy the code
  • Configuration mode

  • Obtaining the egress IP address
curl http://www.cip.cc/



or



Browser Direct access

http://httpbin.org/ip

Copy the code
  • Gets the pool of available agents
https://gitee.com/pingfanrenbiji/proxy_pool

Copy the code

Emulates a browser request to prevent interception by the requested party

Copy the code


User-agent is reset with each request

12306 represents different browser requests

Prevent interception

Copy the code

Request Frequency Settings


The interval between two HTTP requests is a random number between 0 and 1 seconds

Prevents frequent request 12306 from being blocked

Copy the code

conclusion

My ticket is still in the grab 😂

I also wish everyone can grab the right ticket

Copy the code