try: room_desc = '' if each_hotel['rp'] != 'none': room_desc += each_hotel['rp'] if each_hotel['roomStaticDescription'] != '': room_desc += each_hotel['roomStaticDescription'] room.room_desc = re.sub('<.*?>', '', room_desc) except Exception, e: logger.info('Cannot parse this room description with error: ' + str(e)) try: if '可以免费取消' in each_hotel['cancellationPolicyNew'] or '可以免费取消' \ in each_hotel['cancellationPolicy']: room.is_cancel_free = 'Yes' except Exception, e: logger.info('Cannot parse cancel info with error: ' + str(e)) try: bed_type = each_hotel['bedTypes'][0]['description'] room.bed_type = str(bed_type) except Exception, e: logger.info('Cannot parse bed type of this room with error: ' + str(e)) try: size_num_temp = room.room_desc.find('平方米') if size_num_temp > 0: size_content = room.room_desc[:size_num_temp] size_num_temp2 = size_content.rfind('(')
else: if len(each_room[3]) < 20: room.room_type = each_room[3] else: room.room_type = 'NULL' if each_room[0] != u'nbsp;': room.price = each_room[0] room.has_breakfast = each_room[1] room.room_desc = each_room[3] if '免费WiFi' in room.room_desc: room.is_wifi_free = 'Yes' if '免费取消' in room.room_desc: room.is_cancel_free = 'Yes' room.currency = 'CNY' room.source = 'youzhan' room.source_hotelid = hotel_id room.check_in = from_date room.check_out = to_date room_tuple = (room.hotel_name,room.city,room.source,room.source_hotelid,\ room.source_roomid,room.real_source,room.room_type,room.occupancy,\ room.bed_type,room.size,room.floor,room.check_in,room.check_out,room.price,\ room.tax,room.currency,room.is_extrabed,room.is_extrabed_free,room.has_breakfast,\ room.is_breakfast_free,room.is_cancel_free,room.room_desc) room_list.append(room_tuple) else:
room.check_in = check_in room.check_out = check_out try: room.real_source = real_source_pat.findall(each_room_info)[0] room.price = price_pat.findall(each_room_info)[0].replace( ' ', '').replace(',', '') except Exception, e: #logger.error('Can not parse important info of this room! Detail: ' + str(e)) return rooms other_info = '' try: other_info = other_info_pat.findall(each_room_info)[0] if '免费取消' in other_info: room.is_cancel_free = 'Yes' else: room.is_cancel_free = 'No' except: room.is_cancel_free = 'No' try: room_desc_temp = room_desc_pat.findall(each_room_info)[0] room_desc = fan_to_jian(room_desc_temp) room.room_desc = room_desc if '含早餐' in other_info or 'Breakfast' in room_desc: room.has_breakfast = 'Yes' room.is_breakfast_free = 'Yes' else: logger.info('Cannot parse breakfast info!')
room.source = 'biyi' room.check_in = check_in room.check_out = check_out try: room.real_source = real_source_pat.findall(each_room_info)[0] room.price = price_pat.findall(each_room_info)[0].replace(' ','').replace(',','') except Exception, e: #logger.error('Can not parse important info of this room! Detail: ' + str(e)) return rooms other_info = '' try: other_info = other_info_pat.findall(each_room_info)[0] if '免费取消' in other_info: room.is_cancel_free = 'Yes' else: room.is_cancel_free = 'No' except: room.is_cancel_free = 'No' try: room_desc_temp = room_desc_pat.findall(each_room_info)[0] room_desc = fan_to_jian(room_desc_temp) room.room_desc = room_desc if '含早餐' in other_info or 'Breakfast' in room_desc: room.has_breakfast = 'Yes' room.is_breakfast_free = 'Yes' else: logger.info('Cannot parse breakfast info!')