1 |
|
2 | var tr = require('tor-request');
|
3 | var general = {
|
4 | "generateDeviceID": function generateDeviceID(show = false) {
|
5 |
|
6 |
|
7 | let nr1 = Math.floor((Math.random() * 9999) + 1000);
|
8 | let nr2 = Math.floor((Math.random() * 9999) + 1000);
|
9 | let nr3 = Math.floor((Math.random() * 1) + 10);
|
10 | if(show)
|
11 | console.log('generateDeviceID: '+ `72331403-${nr1}-${nr2}-${nr3}`)
|
12 |
|
13 | return `72331403-${nr1}-${nr2}-${nr3}`
|
14 | },
|
15 | "getNewIP": function getNewIP(ischanging=false) {
|
16 |
|
17 | return new Promise(resolve=>{
|
18 |
|
19 | console.log('old ip: ' + currentip);
|
20 |
|
21 | hp_bot.general.generateDeviceID(true);
|
22 |
|
23 | if(ischanging)
|
24 | socket.emit('newip',slave, async function(status) {
|
25 | console.log("callback")
|
26 | currentip = await _SERVER.showExternalIP(false)
|
27 |
|
28 | if(!currentip)
|
29 | setTimeout(()=>{getNewIP();},1000);
|
30 | else
|
31 | {
|
32 | console.log("new ip:"+currentip)
|
33 | resolve(currentip)
|
34 | }
|
35 | });
|
36 |
|
37 | else{
|
38 | setTimeout(()=>{
|
39 | resolve(currentip)
|
40 | },40000)
|
41 | }
|
42 | })
|
43 | },
|
44 | "getXMLData": function fetchIphoneXMLData(adult,start,end,city,cityid) {
|
45 | return new Promise(resolve=>{
|
46 | const devid = general.generateDeviceID();
|
47 | const _url = `https://iphone-xml.booking.com/json/bookings.getHotelAvailabilityMobile?detail_level=1&genius_freebies=2&show_distance_cc=1&request_less_fields=2&show_facilities_review_score=1&show_last_minute_saving=1&include_translations=2&add_bh_info=1&languagecode=de&urgency=1&include_taxes=1&include_count=1&location_source=autocomplete&show_price_trend=1&show_deals=flash%2Clastm%2Csmart%2Cgenius&children_qty=0&low_av_alternatives=0&&&order_by=popularity&show_if_class_is_estimated=1&show_categories=v3&show_location_score=1&show_last_reservation_text=1&show_reinforcement_text=v2&show_filtered_facilities=1&show_if_no_cc_allowed=2&show_soldout=1&show_is_personalized_result=0&show_flash_saving=1&max_persons=-2&use_direct_payment=1&add_ctrip_info=1&include_rack_rate_savings=1&&include_url=1&bh_alt_urgency_msg=1&show_refundable=1&check_price_is_final=1&show_extra_charges=1&room_qty=1&show_if_city_center=1&available_rooms=0&price_buckets=100&flash_deals_amount_if_unsigned=2&show_low_availability=2&show_business_badge=1&autoextend=1&user_os=6.0.1&user_version=11.3.1-android&network_type=wifi&bt=1&arrival_date=${start}&departure_date=${end}&city_ids=${cityid.replace('city=', '').replace('|si=ai%2Cco%2Cci%2Cre%2Cdi', '')}&rows=5000&device_id=${devid}da-ef8edab1ad7f&guest_qty=${adult}`;
|
48 | const options = {
|
49 | headers: {
|
50 | 'Content-Type' : 'application/x-www-form-urlencoded',
|
51 | 'Authorization': 'Basic dGhlc2FpbnRzYnY6ZGdDVnlhcXZCeGdN'
|
52 | },
|
53 | url: _url,
|
54 | timeout: 900000
|
55 | };
|
56 |
|
57 |
|
58 | tr.request(options, function (err, resp, body) {
|
59 | console.log(body)
|
60 | resolve(JSON.parse(body));
|
61 | })
|
62 | })
|
63 | }
|
64 | }
|
65 |
|
66 | tr.request('https://api.ipify.org', function (err, res, body) {
|
67 | if (!err && res.statusCode == 200)
|
68 | {
|
69 | console.log("Your public (through Tor) IP is: " + body);
|
70 | }else
|
71 | console.log(err)
|
72 | });
|
73 |
|
74 | general.getXMLData(1,'2017-10-15','2017-10-17','bern','-2551235') |
\ | No newline at end of file |