-
Notifications
You must be signed in to change notification settings - Fork 0
/
esan-functions.py
102 lines (79 loc) · 3.08 KB
/
esan-functions.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
import requests, json, time, csv
#Go0GWAmeIiqP96f0nSh3TAXP3enAA53g
current_year = time.strftime("%Y")
current_month = time.strftime("%m")
current_year_month = current_year + "-" + current_month
print (current_year_month)
print (current_year_month)
# print(future_year_month)
# origin = "NYC"
# destination = "LAS"
# departure_date = current_year_month + "--" + future_year_month
# print departure_date
x = "https://api.sandbox.amadeus.com/v1.2/points-of-interest/yapq-search-text?apikey=Go0GWAmeIiqP96f0nSh3TAXP3enAA53g&city_name=Tel%20Aviv"
#print (current_year_month)
r = requests.get(x)
data = json.loads(r.content)
# print data
# THESE ARE THE ARRAYS THAT YOU NEED
num_range = len(data['points_of_interest'])
attractions = range(num_range) #NAMES OF THE ATTRACTION
description = range(num_range) #DESCRIPTIONS OF THE ATTRACTION
pictures = range(num_range) #9 INSTAGRAM PHOTOS
grade = range(num_range) # DON'T NEED THIS
# pictures2d = range(num_range)
# index = range(num_range)
# full_attract = []
# #price_arr = range(num_range)
# #airline_arr = range(num_range)
# # data_dict = {}
for x in xrange(0,3):
# pictures.insert(x, data['points_of_interest'][x]['main_image'])
attractions.insert(x, data['points_of_interest'][x]['title'])
grade.insert(x, data['points_of_interest'][x]['grades']['city_grade'])
description.insert(x, data['points_of_interest'][x]['details']['description'])
# print pictures[x]
# print attractions[x]
# print grade[x]
# print description[x]
# full_attract = []
# for x in range(0, 3):
# full_attract.append([attractions[x],description[x],pictures[x]])
# print full_attract[x]
for x in xrange(0, num_range):
pictures.insert(x, data['points_of_interest'][x]['main_image'])
print pictures[x]
# for y in range(3)
# pictures2d[x].insert(data['points_of_interest'][x]['contexual_images']['medium'][y]['url'])
# print pictures2d[x][y]
# description.insert(x, data['points_of_interest'][x]['description'])
# index.append(x)
#price_arr.insert(x,data['results'][x]['price'])
# print price_arr[x]
# print "....."
#airline_arr.insert(x, data['results'][x]['airline'])
# print airline_arr[x]
# print "--------"
# data_dict= {data['results'][x]['departure_date']:data['results'][x]['price']}
# print(data_dict)
double_list = []
for x in range(0, num_range):
double_list.append([attractions[x],description[x]])
print double_list[x]
json.dumps(double_list)
# double_list = sorted(double_list, reverse = True)
# print double_list
# # f = open("resources/output.csv" , "wt")
# for x in xrange(3):
# full_attract.append([attractions[index[x]], description[index[x]],pictures[index[x]]])
# pictures.insert(x, data['points_of_interest'][double_list[x][1]]['main_image'])
# attractions.insert(x, data['points_of_interest'][double_list[x][1]]['title'])
# description.insert(x, data['points_of_interest'][double_list[x][1]]['description'])
#grade.insert(x, data['points_of_interest'][x]['city_grade'])
# try:
# writer = csv.writer(f)
# writer.writerow(('Departure Date','Price'))
# for i in range(num_range):
# writer.writerow((double_list[i][0],double_list[i][1]))
# finally:
# f.close()