// ==UserScript== // @name jetstar机票获取 // @namespace http://tampermonkey.net/ // @version 0.11 // @description try to take over the world! // @author You // @match https://booking.jetstar.com/cn/zh/booking/* // @icon https://www.google.com/s2/favicons?sz=64&domain=jetstar.com // @require http://cdn.bootcss.com/jquery/1.11.2/jquery.js // @require https://scriptcat.org/lib/513/2.0.0/ElementGetter.js // @grant GM_xmlhttpRequest // ==/UserScript== (function() { 'use strict'; var start = new Date().getTime(); var monkey_url = 'http://127.0.0.1:8883/airLines'; // ————————调试部分———————— elmGetter.selector('css'); const wenzi = document.querySelector("div.display-currency-AUD > div:nth-child(3) > div.columns > div.js-fare-row > div.js-fare-row-summary > div.flight-card-itinerary > div.flight-card-itinerary-row > div:nth-child(1) > div.js-departure-time") elmGetter.each('*', wenzi, el => { console.log(el.cloneNode(true)); console.log($(wenzi).text());//这个就是我想要得到的结果 }); // ————————调试部分结束———————— elmGetter.selector($); elmGetter.each('div.display-currency-AUD div.row', company_name => { console.info('page is fully loaded'); var dataList = []; var chufashijian = company_name.find('div.flight-card-itinerary-row div:nth-child(1)').find('div.itinerary-info__time ').text(); var chufajichang = company_name.find('div.flight-card-itinerary-row div:nth-child(1)').find('div.itinerary-info__airport').text(); var daodashijian = company_name.find('div.flight-card-itinerary-row div:nth-child(3)').find('div.itinerary-info__time ').text(); var daodajichang = company_name.find('div.flight-card-itinerary-row div:nth-child(3)').find('div.itinerary-info__airport').text(); var xingchengshijian = company_name.find('strong.travelduration').text(); var price = company_name.find('div.pricepoint span.pricepoint__middle').text(); if (price){ dataList.push({ '出发时间': chufashijian, '出发机场': chufajichang, '到达时间': daodashijian, '到达机场': daodajichang, '行程时间': xingchengshijian, '机票价格': price }) console.info(dataList); var end = new Date().getTime(); var spend_time = (end - start)/1000; GM_xmlhttpRequest({ method: "POST", url: monkey_url, data : JSON.stringify({'数据':dataList,'从发送请求到接收到该条数据所花费时间':spend_time + '秒'}), onload: function(response) { //这里写处理函数 console.log(response); console.log(dataList); const t3 = Date.now(); console.log(t3-start); //window.close(); } }); } }); })();