コード例 #1
0
    for each_hotel in content_json:
        room = Room()

        try:
            room_type = str(each_hotel['RoomName'])
            num_temp1 = room_type.find(',')
            if num_temp1 > 0:
                room.room_type = room_type[:num_temp1]
            else:
                room.room_type = room_type
        except Exception, e:
            logger.error('Cannot paese room type of this hotel!' + str(e))

        try:
            room.source_roomid = each_hotel['RoomId']
        except Exception, e:
            logger.info('Cannot parse this room id with error: ' + str(e))

        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:
コード例 #2
0
                'ctripHotel::parseRoom',
                ['Cannot parse this hotel', str(e)])
        #print room.source_hotelid

        try:
            each_room_content_list = rateplan_pat.findall(each_hotel_content)
            if len(each_room_content_list) == 0:
                _ERROR('ctripHotel::parseRoom', ['Parse this room failed'])
                return room_list
        except Exception, e:
            _ERROR('ctripHotel::parseRoom', ['Parse this room failed', e])
            return room_list
        for each_room_content in each_room_content_list:
            #print each_room_content
            try:
                room.source_roomid = pattern_search(roomcode_pat,
                                                    each_room_content)
            except Exception, e:
                _ERROR('ctripHotel::parseRoom',
                       ['Parse this room failed',
                        str(e)])
                return room_list

            try:
                #print 'okkkkkkkkkkkkkkkkkkkkkkkkkkkkkk'
                room.room_type = room_type_pat.findall(each_room_content)[0]
            except:
                #print 'faillllllllllllllllleddddddddddddddddddd'
                try:
                    room_type_info = room_type_pat2.findall(
                        each_room_content)[0]
                    #print '^^--^^'
コード例 #3
0
ファイル: elongHotelRoomParser.py プロジェクト: dangpu/momoko
    
    for each_hotel in content_json:
        room = Room()

        try:
            room_type = str(each_hotel['RoomName'])
            num_temp1 = room_type.find(',')
            if num_temp1 > 0:
                room.room_type = room_type[:num_temp1]
            else:
                room.room_type = room_type
        except Exception,e:
            logger.error('Cannot paese room type of this hotel!' + str(e))

        try:
            room.source_roomid = each_hotel['RoomId']
        except Exception, e:
            logger.info('Cannot parse this room id with error: ' + str(e))

        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 '可以免费取消' \
コード例 #4
0
                if '免费取消' in cancel_content:
                    room.is_cancel_free = 'Yes'
             
                breakfast_content_temp = breakfast_content_pat.findall(each_room_content)[0]
                breakfast_content_temp = '<' + breakfast_content_temp
                breakfast_content = re.sub('<.*?>','',breakfast_content_temp).strip()
                if '早餐' in breakfast_content:
                    room.has_breakfast = 'Yes'
                if '免费' in breakfast_content and '早餐' in breakfast_content:
                    room.has_breakfast = 'Yes'
                    room.is_breakfast_free = 'Yes'
                #print room.price, room.is_cancel_free,room.is_breakfast_free
                try:
                    #print each_room_content
                    room_id = room_id_pat.findall(each_room_content)[0]
                    room.source_roomid = room_id
                except Exception, e:
                    #logger.info('haodingHotel::Cannot parse id of this room!')
                    #logger.info('haodingHotel::' + str(e))
                #print room.source_roomid  
                try:
                    room.occupancy = occupancy_num_pat.findall(each_room_content)[0]
                except:
                    room.occupancy = 2

                try:
                    if city_name_zh == '布达佩斯':
                        hotel_name_info_temp = hotel_name_info_pat.findall(content)[0]
                        hotel_star_temp = hotel_star_pat.findall(hotel_name_info_temp)[0]
                        hotel_star = int(hotel_star_temp)
                        if hotel_star == 5: