-
Notifications
You must be signed in to change notification settings - Fork 1
/
step_one.py
80 lines (69 loc) · 2.2 KB
/
step_one.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
from Flights_scraping_searcher.scraper import scrape
import pandas as pd
while True:
try:
year = int(input("Enter the year in digits: "))
if type(year) == int:
break
else:
raise ValueError
except ValueError:
print("Please enter digits")
print(year)
while True:
try:
month = int(input("Enter the month in digits: "))
if type(month) == int:
break
else:
raise ValueError
except ValueError:
print("Please enter digits")
print(month)
while True:
try:
start_day = int(input("Enter the starting date in digit: "))
if type(start_day) == int:
break
else:
raise ValueError
except ValueError:
print("Please enter digits")
print(start_day)
while True:
try:
end_day = int(input("Enter the ending date: "))
if type(end_day) == int:
break
else:
raise ValueError
except ValueError:
print("Please enter digits")
print(end_day)
while True:
try:
start_destination = input("Enter the starting destination's airport code: ").upper()
if type(start_destination) == str:
break
else:
raise ValueError
except ValueError:
print("Please enter digits")
print(start_destination)
while True:
try:
end_destination = input("Enter the ending destination's airport code: ").upper()
if type(end_destination) == str:
break
else:
raise ValueError
except ValueError:
print("Please enter digits")
print(end_destination)
scraped_results = scrape(year, month, start_day, end_day, start_destination, end_destination)
print(scraped_results)
df = pd.DataFrame(scraped_results, columns=['start_destination', 'end_destination', 'start_date', 'price', 'num_stops',
'airline_names', 'stop_cities', 'journey_duration', 'dep_time', 'dep_meridiem',
'arrival_time', 'arrival_meridiem'])
df.to_csv('{0}.csv'.format("flights_data"), index=False)
print('finished')