-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwww.jetstar.com.no.py
103 lines (87 loc) · 3.42 KB
/
www.jetstar.com.no.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import sys
sys.path.append(".")
import random
from curl_cffi import requests
from pynocaptcha import AkamaiV2Cracker
from utils import __TOKEN__ as USER_TOKEN, __PROXY__starry_keep
version = random.randint(123, 127)
user_agent = random.choice([
f'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{version}.0.0.0 Safari/537.36',
f"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{version}.0.0.0 Safari/537.36"
])
proxy = __PROXY__starry_keep()
session = requests.Session()
session.proxies.update({
"all": "http://" + proxy
})
resp = session.get("https://ipinfo.io/json", headers={
"user-agent": f'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
}, timeout=5).json()
country = resp["country"].lower()
current_ip = resp["ip"]
print(country, current_ip)
cracker = AkamaiV2Cracker(
show_ad=False,
user_token=USER_TOKEN,
href="https://www.jetstar.com/",
# 这个 api 会换, 传不传都行, 传的话要记得每次自己去取最新的, 不然传旧的会过不去
user_agent=user_agent,
country=country,
ip=current_ip,
proxy=proxy,
debug=True
)
ret = cracker.crack()
if ret:
extra = cracker.extra()
session.cookies.update(ret)
headers = {
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'accept-language': extra['accept-language'],
'priority': 'u=0, i',
'referer': 'https://www.jetstar.com/',
'sec-ch-ua': extra['sec-ch-ua'],
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': extra['sec-ch-ua-platform'],
'sec-fetch-dest': 'document',
'sec-fetch-mode': 'navigate',
'sec-fetch-site': 'same-site',
'sec-fetch-user': '?1',
'upgrade-insecure-requests': '1',
'user-agent': extra['user-agent'],
}
params = {
'Currency': 'TWD',
'adults': '1',
'children': '0',
'departuredate1': '2024-08-13',
'departuredate2': '2024-08-15',
'destination1': 'CBR',
'destination2': 'TPE',
'dotcomFCOutboundArrivalTime': '2024-08-14T15:40:00',
'dotcomFCOutboundCorrelationId': 'e1e6aa63-8fec-4f76-b044-b52240f87322',
'dotcomFCOutboundDepartureTime': '2024-08-13T02:40:00',
'dotcomFCOutboundFare': '15513.23',
'dotcomFCOutboundFlightId': '161309528',
'dotcomFCOutboundIncludeMember': 'False',
'dotcomFCOutboundMemberArrivalTime': '2024-08-14T15:40:00',
'dotcomFCOutboundMemberCorrelationId': 'd41a3224-1750-4d5f-8bbe-fe76dbc16eea',
'dotcomFCOutboundMemberDepartureTime': '2024-08-13T02:40:00',
'dotcomFCOutboundMemberFare': '0',
'dotcomFCOutboundMemberFlightId': '161309528',
'dotcomFCOutboundMemberIncludeMember': 'Only',
'dotcomFCOutboundMemberPriceShown': 'false',
'dotcomFCOutboundPriceShown': 'true',
'dotcomFCPricesHidden': 'false',
'dotcomFCReturnMemberPriceShown': 'false',
'dotcomFCReturnPriceShown': 'false',
'infants': '0',
'origin1': 'TPE',
'origin2': 'CBR',
}
response = session.get(
'https://booking.jetstar.com/hk/zh/booking/search-flights',
params=params,
headers=headers,
)
print(response.status_code, response.text)