我需要在列表中解析大量的URL。每次迭代都是时间昂贵的,我更喜欢在几个线程中进行。做for
循环是否安全,每次迭代开始一个新的线程及其位置,或者我必须拆分列表并分别发送任务(新的python,我知道情况并非如此,但仍然......) 。我只是想避免任何类型的线程冲突。提前谢谢!
#This is what i have so far:
ignore_list = []
counter = 0
for index in results:
sail = index['d']['ResultItems']
for rw in sail:
destination = match_by_meta(index['d']['ErrorMessage'])
destination_code = destination[1]
destination_name = destination[0]
code = rw['VirtualItineraryCode']
cruise_line_name = "Costa Cruises"
number_of_nights = rw['Duration']
vessel_name = rw['Ship']
vessel_id = get_vessel_id(vessel_name)
cruise_id = "4"
brochure_name = rw['Description']
itinerary_url = rw['CruiseDetailURL']
for sailing in rw['AllCruiseInfo']:
itinerary_id = sailing['CruiseCode']
if itinerary_id in doubles:
continue
else:
doubles.append(itinerary_id)
counter += 1
sail_date = sailing['DepartureDateFormatted']
print(counter, brochure_name)
return_date = calculate_days(sail_date, number_of_nights)
cruise_url = build_cruise_url(itinerary_url, itinerary_id)
prices = get_prices(cruise_url)
interior_bucket_price = prices[0]
ocean_view_bucket_price = prices[1]
balcony_bucket_price = prices[2]
suite_bucket_price = prices[3]
special = False
temp = [destination_code, destination_name, vessel_id, vessel_name, cruise_id,
cruise_line_name,
itinerary_id, brochure_name, number_of_nights, sail_date, return_date,
interior_bucket_price, ocean_view_bucket_price, balcony_bucket_price,
suite_bucket_price]
if "Costa Deliziosa" in vessel_name:
dates = [['11/27/2015', '12/20/2015'], ['11/27/2015', '12/28/2015'], ['12/2/2015', '12/20/2015'],
['12/2/2015', '12/21/2015'], ['12/2/2015', '12/28/2015'], ['11/27/2016', '12/28/2016'],
['12/1/2016', '12/21/2016'], ['12/2/2016', '12/21/2016'], ['12/2/2016', '12/28/2016'],
['3/8/2017', '4/5/2017'], ['3/8/2017', '4/9/2017'], ['3/18/2017', '4/5/2017']]
for d in dates:
if sail_date == d[0] and return_date == d[1]:
special = True
break
else:
special = False
elif 'Costa Diadema' in vessel_name:
dates = [['12/10/2015', '12/17/2015'], ['12/17/2015', '12/24/2015'], ['12/24/2015', '12/31/2015'],
['1/7/2016', '1/14/2016'], ['1/14/2016', '1/21/2016'], ['1/21/2016', '1/28/2016'],
['1/28/2016', '2/4/2016'], ['2/4/2016', '2/11/2016'], ['2/11/2016', '2/18/2016'],
['2/18/2016', '2/25/2016'], ['2/25/2016', '3/3/2016'], ['3/3/2016', '3/10/2016'],
['3/10/2016', '3/17/2016'], ['3/17/2016', '3/24/2016'], ['4/7/2016', '4/14/2016'],
['4/14/2016', '4/21/2016'], ['4/21/2016', '4/28/2016'], ['4/28/2016', '5/5/2016'],
['5/5/2016', '5/12/2016'], ['5/12/2016', '5/19/2016'], ['5/19/2016', '5/26/2016'],
['5/26/2016', '6/2/2016'], ['6/2/2016', '6/9/2016'], ['6/9/2016', '6/16/2016'],
['6/16/2016', '6/23/2016'], ['6/17/2016', '6/24/2016'], ['6/23/2016', '6/30/2016'],
['6/24/2016', '7/1/2016'], ['6/30/2016', '7/7/2016'], ['7/1/2016', '7/8/2016'],
['7/7/2016', '7/14/2016'], ['7/8/2016', '7/15/2016'], ['7/14/2016', '7/21/2016'],
['7/15/2016', '7/22/2016'], ['7/21/2016', '7/28/2016'], ['7/22/2016', '7/29/2016'],
['7/28/2016', '8/4/2016'], ['7/29/2016', '8/5/2016'], ['8/4/2016', '8/11/2016'],
['8/5/2016', '8/12/2016'], ['8/11/2016', '8/18/2016'], ['8/12/2016', '8/19/2016'],
['8/18/2016', '8/25/2016'], ['8/19/2016', '8/26/2016'], ['8/25/2016', '9/1/2016'],
['8/26/2016', '9/2/2016'], ['9/1/2016', '9/8/2016'], ['9/2/2016', '9/9/2016'],
['9/8/2016', '9/15/2016'], ['9/9/2016', '9/16/2016'], ['9/15/2016', '9/22/2016'],
['9/22/2016', '9/29/2016'], ['9/29/2016', '10/6/2016'], ['10/6/2016', '10/13/2016'],
['10/13/2016', '10/20/2016'], ['10/20/2016', '10/27/2016'], ['10/27/2016', '11/3/2016'],
['11/3/2016', '11/10/2016'], ['11/10/2016', '11/17/2016'], ['11/17/2016', '11/24/2016'],
['11/24/2016', '12/1/2016'], ['1/5/2017', '1/12/2017'], ['1/12/2017', '1/19/2017'],
['1/19/2017', '1/26/2017'], ['1/26/2017', '2/2/2017'], ['1/30/2017', '2/6/2017'],
['2/2/2017', '2/9/2017'], ['2/9/2017', '2/16/2017'], ['2/16/2017', '2/23/2017'],
['2/23/2017', '3/2/2017'], ['3/2/2017', '3/9/2017'], ['3/9/2017', '3/16/2017'],
['3/16/2017', '3/23/2017'], ['3/23/2017', '3/30/2017'], ['3/30/2017', '4/6/2017'],
['4/6/2017', '4/13/2017'], ['4/13/2017', '4/20/2017'], ['4/20/2017', '4/27/2017'],
['4/27/2017', '5/4/2017'], ['5/4/2017', '5/11/2017'], ['5/11/2017', '5/18/2017'],
['5/18/2017', '5/25/2017'], ['6/2/2017', '6/9/2017'], ['6/9/2017', '6/16/2017'],
['6/16/2017', '6/23/2017'], ['6/23/2017', '6/30/2017'], ['6/30/2017', '7/7/2017'],
['7/7/2017', '7/14/2017'], ['7/14/2017', '7/21/2017'], ['7/21/2017', '7/28/2017'],
['7/28/2017', '8/4/2017'], ['8/4/2017', '8/11/2017'], ['8/11/2017', '8/18/2017'],
['8/18/2017', '8/25/2017'], ['8/25/2017', '9/1/2017'], ['9/1/2017', '9/8/2017'],
['9/8/2017', '9/15/2017'], ['9/15/2017', '9/22/2017'], ['9/22/2017', '9/29/2017'],
['10/5/2017', '10/12/2017'], ['10/12/2017', '10/19/2017'], ['10/19/2017', '10/26/2017'],
['10/26/2017', '11/2/2017'], ['11/2/2017', '11/9/2017'], ['11/9/2017', '11/16/2017'],
['11/16/2017', '11/23/2017'], ['11/23/2017', '11/30/2017'], ['11/30/2017', '12/7/2017'],
['12/9/2017', '12/16/2017'], ['12/16/2017', '12/22/2017'], ['12/22/2017', '12/29/2017'],
['12/29/2017', '1/6/2018'], ['1/6/2018', '1/13/2018'], ['1/13/2018', '1/20/2018'],
['1/20/2018', '1/27/2018'], ['2/1/2018', '2/8/2018'], ['2/8/2018', '2/15/2018'],
['2/15/2018', '2/22/2018'], ['2/22/2018', '3/1/2018'], ['3/1/2018', '3/8/2018'],
['3/8/2018', '3/15/2018'], ['3/15/2018', '3/22/2018'], ['3/22/2018', '3/29/2018'],
['3/29/2018', '4/5/2018']]
for d in dates:
if sail_date == d[0] and return_date == d[1]:
special = True
break
else:
special = False
elif "Costa Fascinosa" in vessel_name:
dates = [['10/3/2015', '10/10/2015'], ['10/10/2015', '10/17/2015'], ['10/17/2015', '10/24/2015'],
['10/24/2015', '10/31/2015'], ['10/31/2015', '11/7/2015'], ['11/7/2015', '11/14/2015'],
['11/9/2015', '11/16/2015'], ['11/14/2015', '11/21/2015'], ['11/15/2015', '11/22/2015'],
['11/21/2015', '11/28/2015'], ['3/20/2016', '3/27/2016'], ['3/27/2016', '4/3/2016'],
['4/3/2016', '4/10/2016'], ['4/10/2016', '4/17/2016'], ['4/17/2016', '4/24/2016'],
['4/24/2016', '5/1/2016'], ['5/1/2016', '5/8/2016'], ['5/8/2016', '5/15/2016'],
['5/15/2016', '5/22/2016'], ['5/22/2016', '5/29/2016'], ['5/29/2016', '6/5/2016'],
['6/5/2016', '6/12/2016'], ['6/12/2016', '6/19/2016'], ['6/19/2016', '6/26/2016'],
['6/26/2016', '7/3/2016'], ['7/3/2016', '7/10/2016'], ['7/10/2016', '7/17/2016'],
['7/17/2016', '7/24/2016'], ['7/24/2016', '7/31/2016'], ['7/31/2016', '8/7/2016'],
['8/7/2016', '8/14/2016'], ['8/14/2016', '8/21/2016'], ['8/21/2016', '8/28/2016'],
['8/28/2016', '9/4/2016'], ['9/4/2016', '9/11/2016'], ['9/11/2016', '9/18/2016'],
['9/18/2016', '9/25/2016'], ['9/25/2016', '10/2/2016'], ['10/2/2016', '10/9/2016'],
['10/9/2016', '10/16/2016'], ['10/16/2016', '10/23/2016'], ['10/23/2016', '10/30/2016'],
['10/30/2016', '11/6/2016'], ['11/6/2016', '11/13/2016'], ['11/13/2016', '11/20/2016'],
['11/20/2016', '11/27/2016'], ['11/27/2016', '12/2/2016'], ['11/27/2016', '12/4/2016'],
['12/11/2016', '12/22/2016'], ['12/22/2016', '12/27/2016'], ['12/27/2016', '1/7/2017'],
['1/7/2017', '1/18/2017'], ['1/18/2017', '1/29/2017'], ['1/28/2017', '2/4/2017'],
['2/4/2017', '2/11/2017'], ['2/11/2017', '2/18/2017'], ['2/18/2017', '2/25/2017'],
['2/25/2017', '3/4/2017'], ['3/4/2017', '3/11/2017'], ['3/11/2017', '3/18/2017'],
['3/18/2017', '3/25/2017'], ['3/19/2017', '3/26/2017'], ['3/26/2017', '4/2/2017'],
['4/2/2017', '4/9/2017'], ['4/7/2017', '4/14/2017'], ['4/14/2017', '4/21/2017']]
for d in dates:
if sail_date == d[0] and return_date == d[1]:
special = True
break
else:
special = False
elif "Costa Favolosa" in vessel_name:
dates = [['10/1/2015', '10/8/2015'], ['10/8/2015', '10/15/2015'], ['10/15/2015', '10/22/2015'],
['10/22/2015', '10/29/2015'], ['10/29/2015', '11/5/2015'], ['11/5/2015', '11/12/2015'],
['11/12/2015', '11/19/2015'], ['11/19/2015', '11/26/2015'], ['9/13/2016', '9/22/2016'],
['9/22/2016', '10/1/2016'], ['10/1/2016', '10/10/2016'], ['10/10/2016', '10/19/2016'],
['10/19/2016', '10/23/2016'], ['10/23/2016', '10/28/2016'], ['10/28/2016', '11/2/2016'],
['11/2/2016', '11/7/2016'], ['11/7/2016', '11/12/2016'], ['11/12/2016', '11/17/2016'],
['4/15/2017', '4/19/2017'], ['4/19/2017', '4/22/2017'], ['4/22/2017', '4/26/2017'],
['4/26/2017', '4/29/2017'], ['4/29/2017', '5/3/2017'], ['5/3/2017', '5/8/2017'],
['5/8/2017', '5/11/2017'], ['5/11/2017', '5/15/2017'], ['5/15/2017', '5/26/2017'],
['5/26/2017', '6/2/2017'], ['6/2/2017', '6/9/2017'], ['6/9/2017', '6/16/2017'],
['6/16/2017', '6/23/2017'], ['6/23/2017', '6/30/2017'], ['6/30/2017', '7/7/2017'],
['7/7/2017', '7/14/2017'], ['7/14/2017', '7/21/2017'], ['7/21/2017', '7/28/2017'],
['7/28/2017', '8/4/2017'], ['8/4/2017', '8/11/2017'], ['8/11/2017', '8/18/2017'],
['8/18/2017', '8/25/2017'], ['8/25/2017', '9/1/2017'], ['9/1/2017', '9/8/2017'],
['9/8/2017', '9/20/2017'], ['9/21/2017', '9/26/2017'], ['9/26/2017', '10/1/2017'],
['10/1/2017', '10/6/2017'], ['10/6/2017', '10/11/2017'], ['10/16/2017', '10/21/2017'],
['10/21/2017', '10/26/2017'], ['10/26/2017', '10/31/2017'], ['10/31/2017', '11/5/2017'],
['11/5/2017', '11/10/2017'], ['11/9/2017', '11/14/2017'], ['11/10/2017', '11/15/2017'],
['11/14/2017', '11/19/2017'], ['11/15/2017', '11/20/2017'], ['11/19/2017', '11/24/2017']]
for d in dates:
if sail_date == d[0] and return_date == d[1]:
special = True
break
else:
special = False
elif "Costa Luminosa" in vessel_name:
dates = [['12/27/2015', '1/5/2016'], ['12/24/2016', '12/31/2016'], ['12/31/2016', '1/6/2017']]
for d in dates:
if sail_date == d[0] and return_date == d[1]:
special = True
break
else:
special = False
elif "Costa Magica" in vessel_name:
dates = [['12/12/2015', '12/19/2015'], ['12/19/2015', '12/26/2015'], ['12/26/2015', '1/2/2016'],
['1/2/2016', '1/9/2016'], ['1/9/2016', '1/16/2016'], ['1/16/2016', '1/23/2016'],
['1/23/2016', '1/30/2016'], ['1/30/2016', '2/6/2016'], ['2/6/2016', '2/13/2016'],
['2/13/2016', '2/20/2016'], ['2/20/2016', '2/27/2016'], ['2/27/2016', '3/5/2016'],
['3/5/2016', '3/12/2016'], ['3/6/2016', '3/20/2016'], ['3/12/2016', '3/19/2016'],
['3/19/2016', '3/26/2016'], ['5/19/2017', '5/31/2017'], ['6/9/2017', '6/18/2017'],
['6/18/2017', '7/2/2017'], ['7/11/2017', '7/20/2017']]
for d in dates:
for d in dates:
if sail_date == d[0] and return_date == d[1]:
special = True
break
else:
special = False
elif "Costa Mediterranea" in vessel_name:
dates = [['11/13/2015', '11/20/2015'], ['1/3/2017', '1/9/2017'], ['1/21/2017', '2/3/2017'],
['2/3/2017', '2/10/2017'], ['2/10/2017', '2/17/2017'], ['2/17/2017', '2/24/2017'],
['2/24/2017', '3/3/2017'], ['3/3/2017', '3/10/2017'], ['3/10/2017', '3/17/2017'],
['3/17/2017', '3/24/2017'], ['3/24/2017', '3/31/2017'], ['3/31/2017', '4/3/2017'],
['4/2/2017', '4/5/2017'], ['4/15/2017', '4/20/2017'], ['4/30/2017', '5/10/2017'],
['10/4/2017', '10/14/2017'], ['10/14/2017', '10/24/2017'], ['10/24/2017', '11/3/2017'],
['11/3/2017', '11/13/2017'], ['11/24/2017', '12/15/2017'], ['11/24/2017', '12/16/2017'],
['12/16/2017', '12/23/2017'], ['12/23/2017', '12/30/2017'], ['12/30/2017', '1/6/2018'],
['1/6/2018', '1/13/2018'], ['1/20/2018', '1/27/2018'], ['1/27/2018', '2/3/2018'],
['2/3/2018', '2/10/2018'], ['2/10/2018', '2/17/2018'], ['2/17/2018', '2/24/2018'],
['2/24/2018', '3/3/2018']]
for d in dates:
if sail_date == d[0] and return_date == d[1]:
special = True
break
else:
special = False
elif "Costa neoClassica" in vessel_name:
dates = [['10/8/2015', '10/18/2015'], ['10/18/2015', '10/28/2015'], ['10/28/2015', '11/7/2015'],
['11/2/2015', '11/16/2015'], ['11/7/2015', '11/17/2015'], ['11/9/2015', '11/23/2015'],
['3/25/2017', '4/14/2017'], ['11/17/2015', '12/14/2015'], ['11/27/2016', '12/20/2016'],
['12/20/2016', '12/27/2016'], ['12/27/2016', '1/3/2017'], ['1/3/2017', '1/10/2017'],
['1/10/2017', '1/31/2017'], ['1/31/2017', '2/21/2017'], ['2/21/2017', '3/14/2017'],
['3/14/2017', '4/8/2017']]
for d in dates:
if sail_date == d[0] and return_date == d[1]:
special = True
break
else:
special = False
elif "Costa neoRomantica" in vessel_name:
dates = [['11/17/2015', '11/29/2015'], ['11/17/2015', '12/12/2015'], ['3/29/2016', '4/13/2016'],
['4/13/2016', '4/28/2016'], ['4/28/2016', '5/13/2016'], ['9/15/2016', '9/26/2016'],
['9/15/2016', '10/15/2016'], ['9/17/2016', '9/28/2016'], ['9/26/2016', '10/7/2016'],
['9/28/2016', '10/9/2016'], ['10/7/2016', '10/18/2016'], ['10/18/2016', '10/29/2016'],
['10/20/2016', '10/31/2016'], ['10/29/2016', '11/9/2016'], ['10/31/2016', '11/11/2016'],
['11/9/2016', '11/20/2016'], ['11/11/2016', '11/22/2016'], ['11/20/2016', '12/1/2016'],
['3/4/2017', '3/31/2017']]
for d in dates:
if sail_date == d[0] and return_date == d[1]:
special = True
break
else:
special = False
elif "Costa Pacifica" in vessel_name:
dates = [['9/29/2015', '10/10/2015'], ['10/21/2015', '11/1/2015'], ['11/12/2015', '11/23/2015'],
['11/28/2015', '12/16/2015'], ['3/26/2016', '4/2/2016'], ['4/2/2016', '4/9/2016'],
['4/9/2016', '4/16/2016'], ['4/16/2016', '4/23/2016'], ['4/23/2016', '4/30/2016'],
['4/30/2016', '5/7/2016'], ['9/24/2016', '10/1/2016'], ['10/1/2016', '10/8/2016'],
['10/8/2016', '10/15/2016'], ['10/15/2016', '10/22/2016'], ['10/22/2016', '10/29/2016'],
['10/29/2016', '11/5/2016'], ['11/5/2016', '11/12/2016'], ['11/12/2016', '11/19/2016'],
['11/19/2016', '11/26/2016'], ['11/27/2016', '12/12/2016'], ['11/27/2016', '12/13/2016'],
['2/25/2017', '3/17/2017'], ['3/2/2017', '3/17/2017'], ['3/2/2017', '3/19/2017'],
['3/25/2017', '4/1/2017'], ['4/1/2017', '4/8/2017'], ['4/8/2017', '4/15/2017'],
['4/15/2017', '4/22/2017'], ['4/22/2017', '4/29/2017'], ['4/29/2017', '5/6/2017'],
['5/6/2017', '5/13/2017'], ['5/13/2017', '5/20/2017'], ['5/20/2017', '6/1/2017'],
['9/30/2017', '10/7/2017'], ['10/7/2017', '10/14/2017'], ['10/14/2017', '10/21/2017'],
['10/21/2017', '10/28/2017'], ['10/28/2017', '11/4/2017'], ['11/4/2017', '11/11/2017'],
['11/11/2017', '11/18/2017']]
for d in dates:
if sail_date == d[0] and return_date == d[1]:
special = True
break
else:
special = False
elif "Costa Classica" in vessel_name:
dates = [['11/6/2015', '11/17/2015']]
for d in dates:
if sail_date == d[0] and return_date == d[1]:
special = True
break
else:
special = False
if special:
temp = [destination_code, destination_name, vessel_id, vessel_name, cruise_id,
cruise_line_name,
itinerary_id, brochure_name, number_of_nights, sail_date, return_date,
interior_bucket_price, ocean_view_bucket_price, balcony_bucket_price,
suite_bucket_price]
ignore_list.append(temp)
else:
temp = [destination_code, destination_name, vessel_id, vessel_name, cruise_id,
cruise_line_name,
itinerary_id, brochure_name, number_of_nights, sail_date, return_date,
interior_bucket_price, ocean_view_bucket_price, balcony_bucket_price,
suite_bucket_price]
to_write.append(temp)
def calculate_days(sail_date_param, number_of_nights_param):
date = datetime.datetime.strptime(sail_date_param, "%m/%d/%Y")
try:
calculated = date + datetime.timedelta(days=int(number_of_nights_param))
except ValueError:
calculated = date + datetime.timedelta(days=int(number_of_nights_param.split("-")[1]))
calculated = calculated.strftime("%m/%d/%Y")
return calculated
def build_cruise_url(ur, co):
split = ur.split("-")
return 'http://www.costacruise.com' + split[0] + '-' + split[1] + '-' + co + '.html'
def get_prices(link):
interior_bucket_price1 = "N/A"
ocean_view_bucket_price1 = "N/A"
balcony_bucket_price1 = "N/A"
suite_bucket_price1 = "N/A"
spans = []
price_page = requests.get(link)
soup = BeautifulSoup(price_page.text, 'lxml')
for r in soup.find_all("div", {"class": "cabins clearfix"}):
children = r.find_all("div", {"class": "wrap"})
for child in children:
item = child.text.strip().split('from')
spans.append(item)
for i in range(0, len(spans)):
if spans[i][0].strip() == "Inside":
interior_bucket_price1 = spans[i][1].split('$')[1]
if spans[i][0].strip() == "Outside" or spans[i][0].strip() == 'Ocean View' or spans[i][
0].strip() == 'Oceanview':
ocean_view_bucket_price1 = spans[i][1].split('$')[1]
if spans[i][0].strip() == "Veranda" or spans[i][0].strip() == "Ocean View Balcony":
balcony_bucket_price1 = spans[i][1].split('$')[1]
if spans[i][0].strip() == "Suites" or spans[i][0].strip() == "Suite":
suite_bucket_price1 = spans[i][1].split('$')[1]
if interior_bucket_price1 != "N/A":
if "," in interior_bucket_price1:
interior_bucket_price1 = interior_bucket_price1.replace(",", "")
else:
pass
interior_bucket_price1 = str(int(math.ceil(float(interior_bucket_price1))))
else:
pass
if ocean_view_bucket_price1 != "N/A":
if "," in ocean_view_bucket_price1:
ocean_view_bucket_price1 = ocean_view_bucket_price1.replace(",", "")
else:
pass
ocean_view_bucket_price1 = str(
int(math.ceil(float(ocean_view_bucket_price1))))
else:
pass
if balcony_bucket_price1 != "N/A":
if "," in balcony_bucket_price1:
balcony_bucket_price1 = balcony_bucket_price1.replace(",", "")
else:
pass
balcony_bucket_price1 = str(int(math.ceil(float(balcony_bucket_price1))))
else:
pass
if suite_bucket_price1 != "N/A":
if "," in suite_bucket_price1:
suite_bucket_price1 = suite_bucket_price1.replace(",", "")
else:
pass
suite_bucket_price1 = str(int(math.ceil(float(suite_bucket_price1))))
else:
pass
return [interior_bucket_price1, ocean_view_bucket_price1, balcony_bucket_price1, suite_bucket_price1]
def match_by_meta(param):
# print(param)
if param == "ATLANTIC OCEAN":
result = ['Atlantic Ocean', 'AO']
return result
elif param == "EASTERN CARIBBEAN":
result = ['Carib', 'C']
# print(result)
return result
elif param == "MAR ROSSOARAB":
result = ['Exotics', 'D']
# print(result)
return result
elif param == "EAST MEDITERRANEAN":
result = ['Europe', 'EM']
# print(result)
return result
elif param == "ORIENTAL LANDS":
result = ['Exotics', 'FE']
# print(result)
return result
elif param == "GREATEASTERNCRUISES":
result = ['Exotics', 'ML']
# print(result)
return result
elif param == "INDIAN OCEAN":
result = ['Exotics', 'MU']
# print(result)
return result
elif param == "NORTHERN CAPITALS":
result = ['Europe', 'NC']
# print(result)
return result
elif param == "NORWEGIAN FJORDS":
result = ['Europe', 'NJ']
# print(result)
return result
elif param == "PACIFIC OCEAN":
result = ['South Pacific', 'SP']
# print(result)
return result
elif param == "MAR ROSSO":
result = ['Exotics', 'RS']
# print(result)
return result
elif param == "SOUTH AMERICA":
result = ['South America', 'S']
# print(result)
return result
elif param == "TRANSATLANTIC":
result = ['Europe', 'X']
# print(result)
return result
elif param == "WEST MEDITERRANEAN":
result = ['Europe', 'WM']
# print(result)
return result
def get_vessel_id(ves_name):
if ves_name == "Costa Deliziosa":
return "713"
elif ves_name == "Costa Diadema":
return "858"
elif ves_name == "Costa Fascinosa":
return "755"
elif ves_name == "Costa Favolosa":
return "728"
elif ves_name == "Costa Luminosa":
return "683"
elif ves_name == "Costa Magica":
return "437"
elif ves_name == "Costa Mediterranea":
return "425"
elif ves_name == "Costa neoClassica":
return "403"
elif ves_name == "Costa neoRiviera":
return "881"
elif ves_name == "Costa neoRomantica":
return "79"
elif ves_name == "Costa Pacifica":
return "684"