JavaScript 12306 automatically refresh tickets [to be perfected]

Source: Internet
Author: User
Tags ticket

function Refresh () {
var search_btn = document.getElementById ("query_ticket");
var result_table = document.getElementById ("querylefttable");//table node to get train ticket query results
var book_btns = Result_table. Getelementsbyclassname ("btn72");
Searrch_btn.click ();
Result_table.addeventlistener (' Click ', function (e) {//human Lookup and make a reservation while stopping the script from continuing to refresh
E.target = e.target| | e.srcelement;
if (e.target.nodetype = = = 1 && e.target.nodename = = = ' TD ' && e.target.innertext = = = ' Reservation ') {
Clearinterval (timerid);
}
});
Automatically detect ticket availability and automate bookings
var ticket_76000k11580b_trnode = document.getElementById ("ticket_76000k11580b");//k1158 row node
var k1158b_tdnode = document.getElementById ("yz_76000k11580b");//k1158 Hard Seat node
var k1158_book_tdnode = Ticket_76000k11580b_trnode.getelementsbytagname ("td") [12]; Reservation Ticket Node
If (parseint (k1158b_tdnode.innertext)! = (NaN | | 0)) {
K1158_book_tdnode.click ();
}
}

var Timerid = setinterval (refresh,10000);

JavaScript 12306 automatically refreshes the ticket [to be perfected]

Related Article

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.