File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010
1111if __name__ == "__main__" :
1212
13+
1314 print ("Fetching airports list..." )
15+
16+ airports_headers = {
17+ "Accept" : "application/json" ,
18+ "Origin" : "https://www.flightsfrom.com" ,
19+ "Referer" : "https://www.flightsfrom.com/"
20+ }
1421 response = requests .get (
15- "https://www.flightsfrom.com/airports" , impersonate = "chrome"
22+ "https://www.flightsfrom.com/airports" , impersonate = "chrome" , headers = airports_headers
1623 )
1724 try :
1825 airports_json = json .loads (response .content )
3340
3441 while True :
3542 try :
43+ destinations_headers = {
44+ "Accept" : "text/html" ,
45+ "Origin" : "https://www.flightsfrom.com" ,
46+ "Referer" : "https://www.flightsfrom.com/"
47+ }
3648 response = requests .get (
37- "https://www.flightsfrom.com/%s/destinations" % iata , impersonate = "chrome"
49+ "https://www.flightsfrom.com/%s/destinations" % iata ,
50+ impersonate = "chrome" ,
51+ headers = destinations_headers
3852 )
3953 root = lxml .html .document_fromstring (response .content )
4054 metadata_nodes = root .xpath ('//script[contains(., "window.airport")]' )
You can’t perform that action at this time.
0 commit comments