Example #1
0
                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('(')
                if size_num_temp2 > 0:
                    room_size = size_content[size_num_temp2 + 1:]
                    room.size = room_size.strip().replace(' ', '')
        except Exception, e:
            logger.info('Cannot parse size of this room with error: ' + str(e))
Example #2
0
                logger.info('Cannot parse breakfast info!')
                room.has_breakfast = 'No'
                room.is_breakfast_free = 'No'

            type_num01 = room_desc.find('(')
            type_num02 = room_desc.find('Room')
            if type_num01 > 0:
                room.room_type = room_desc[:type_num01]
            elif type_num02 > 0:
                room.room_type = room_desc[:type_num02 + 4]
            else:
                #logger.info('Cannot parse room type info!')
                room.room_type = room_desc

            if '单人床' in room_desc:
                room.bed_type = '单人床'
            elif '双人床' in room_desc:
                room.bed_type = '双人床'
            elif '大床' in room_desc:
                room.bed_type = '大床'
            else:
                room.bed_type = 'NULL'

            if '双人' in room_desc or 'Double' in room_desc or '双床' in room_desc:
                room.occupancy = 2
            elif '三人' in room_desc or 'Three' in room_desc:
                room.occupancy = 3
            elif '四人' in room_desc or 'Four' in room_desc:
                room.occupancy = 4
            else:
                room.occupancy = 2
Example #3
0
                logger.info('Cannot parse breakfast info!')
                room.has_breakfast = 'No'
                room.is_breakfast_free = 'No'
            
            type_num01 = room_desc.find('(')
            type_num02 = room_desc.find('Room')
            if type_num01 > 0:
                room.room_type = room_desc[:type_num01]
            elif type_num02 > 0:
                room.room_type = room_desc[:type_num02 + 4]
            else:
                #logger.info('Cannot parse room type info!')
                room.room_type = room_desc

            if '单人床' in room_desc:
                room.bed_type = '单人床'
            elif '双人床' in room_desc:
                room.bed_type = '双人床'
            elif '大床' in room_desc:
                room.bed_type = '大床'
            else:
                room.bed_type = 'NULL'

            if '双人' in room_desc or 'Double' in room_desc or '双床' in room_desc:
                room.occupancy = 2
            elif '三人' in room_desc or 'Three' in room_desc:
                room.occupancy = 3
            elif '四人' in room_desc or 'Four' in room_desc:
                room.occupancy = 4
            else:
                room.occupancy = 2
Example #4
0
            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('(')
                if size_num_temp2 > 0:
                    room_size = size_content[size_num_temp2 + 1:]
                    room.size = room_size.strip().replace(' ','')
        except Exception, e:
            logger.info('Cannot parse size of this room with error: ' + str(e))

        except Exception,e:
Example #5
0
            room_type_temp = room_type_pat.findall(each_type_room_content)[0]
            bed_type_temp = bed_type_pat.findall(each_type_room_content)[0]
            room_type_temp = '<' + room_type_temp
            room_type = re.sub('<.*?.>','',room_type_temp).strip()
            bed_type = re.sub('<.*?>','',bed_type_temp).strip()
            #print bed_type
            #if '加床' in bed_type:
            #    room.is_extrabed = 'Yes'
            if '加床' in bed_type:# and '免费' in bed_type:
                room.is_extrabed = 'Yes'
                room.is_extrabed_free = 'Yes'
            room.room_type = room_type.split('\n')[0]
            if '(' in room.room_type:
                room_num = room.room_type.find('(')
                room.room_type = room.room_type[:room_num]
            room.bed_type = bed_type.split('\n')[0]
        except:
            #logger.info('haodingHotel::Cannot parse room_type, bed_type !')
            #logger.info('haodingHotel::' + str(e))
            pass
            
        #print  room.room_type,room.bed_type
        try:
            room_content_list = each_room_content_pat.findall(each_type_room_content)
            if len(room_content_list) == 0:
                continue
        except Exception, e:
            #logger.info('haodingHotel::Parse this room failed with error: ' + str(e))
            continue

        for each_room_content in room_content_list: