示例#1
0
 def item_by_treasure():
     #arrange
     expected = Item()
     expected.id = '11927'
     expected.name = 'Legplates of the Eternal Guardian'
     expected.type = TypeEnum.TYPE_BY_TREASURE
     expected.method = 'Chest of The Seven'
     expected.location = 'Blackrock Depths'
     expected.slot = SlotEnum(7)
     expected.url = 'https://classic.wowhead.com/item=11927/legplates-of-the-eternal-guardian#contained-in-object'
     return expected
示例#2
0
 def item_by_quest_several_same_location():
     #arrange
     expected = Item()
     expected.id = '19383'
     expected.name = 'Master Dragonslayer\'s Medallion'
     expected.location = 'Stormwind City, Orgrimmar'
     expected.type = TypeEnum.TYPE_BY_QUEST
     expected.method = "The Lord of Blackrock"
     expected.slot = SlotEnum(2)
     expected.url = 'https://classic.wowhead.com/item=19383/master-dragonslayers-medallion'
     return expected
示例#3
0
 def item_by_quest():
     #arrange
     expected = Item()
     expected.id = '18469'
     expected.name = 'Royal Seal of Eldre\'Thalas'
     expected.type = TypeEnum.TYPE_BY_QUEST
     expected.method = 'Holy Bologna: What the Light Won\'t Tell You'
     expected.location = 'Dire Maul'
     expected.slot = SlotEnum(12)
     expected.url = 'https://classic.wowhead.com/item=18469/royal-seal-of-eldrethalas'
     return expected
示例#4
0
 def item_several_boss():
     #arrange
     expected = Item()
     expected.id = '19147'
     expected.type = TypeEnum.BY_KILLING
     expected.method = TypeEnum.METHOD_SEVERAL_BOSSESS
     expected.name = 'Ring of Spell Power'
     expected.location = 'Molten Core'
     expected.slot = SlotEnum(11)
     expected.dropRate = TypeEnum.EMPTY
     expected.url = 'https://classic.wowhead.com/item=19147/ring-of-spell-power'
     return expected
示例#5
0
 def item_world_drop():
     #arrange
     expected = Item()
     expected.id = '13102'
     expected.name = 'Cassandra\'s Grace'
     expected.type = TypeEnum.BY_KILLING
     expected.location = TypeEnum.TYPE_BY_WORLD_EVENT
     expected.slot = SlotEnum(1)
     expected.method = TypeEnum.EMPTY
     expected.dropRate = TypeEnum.EMPTY
     expected.url = 'https://classic.wowhead.com/item=13102/gr%C3%A2ce-de-cassandre'
     return expected
示例#6
0
 def item_by_craft_one_location():
     #arrange
     expected = Item()
     expected.id = '14154'
     expected.name = 'Truefaith Vestments'
     expected.type = TypeEnum.TYPE_BY_PROFESSION.replace(
         '{professionName}', 'Tailoring')
     expected.location = 'Stratholme'
     expected.slot = SlotEnum(5)
     expected.dropRate = TypeEnum.EMPTY
     expected.method = TypeEnum.EMPTY
     expected.url = 'https://classic.wowhead.com/item=14154/truefaith-vestments'
     return expected
示例#7
0
 def item_by_craft_with_sublocation():
     #arrange
     expected = Item()
     expected.id = '18405'
     expected.name = 'Belt of the Archmage'
     expected.type = TypeEnum.TYPE_BY_PROFESSION.replace(
         '{professionName}', 'Tailoring')
     expected.location = 'Knot Thimblejack\'s Cache'
     expected.slot = SlotEnum(6)
     expected.dropRate = TypeEnum.EMPTY
     expected.method = TypeEnum.EMPTY
     expected.url = 'https://classic.wowhead.com/item=18405/belt-of-the-archmage'
     return expected
示例#8
0
 def item_test_boss():
     #arrange
     expected = Item()
     expected.id = '16921'
     expected.name = 'Halo of Transcendence'
     expected.location = 'Onyxia\'s Lair'
     expected.type = TypeEnum.BY_KILLING
     expected.method = TypeEnum.METHOD_KILL.replace('{targetName}',
                                                    'Onyxia')
     expected.dropRate = '18.19%'
     expected.slot = SlotEnum(1)
     expected.url = 'https://classic.wowhead.com/item=16921/halo-of-transcendence'
     return expected
示例#9
0
def extractItems(pages):
    lenPages = len(pages)
    for i in range(lenPages):
        page = pages[i]

        log("pages: " + str(i + 1) + '/' + str(lenPages))

        page.metadata['items'] = []
        with FetchHtmls(page.metadata['itemUrls']) as responses:
            for response in responses:
                html = response['content']

                # item global information
                item = Item()
                item.id = extractSingle(RegexEnum.REGEX_ITEM_ID, html)
                item.name = extractSingle(
                    RegexEnum.REGEX_ITEM_NAME.replace('{itemId}', item.id),
                    html)
                item.url = response['origin']
                item.slot = WowHeadEnum[extractSingle(RegexEnum.REGEX_SLOT_ID,
                                                      html)]
                item.phase = page.metadata.get('phase', '')
                item.classe = page.metadata.get('classe', '')
                item.spe = page.metadata.get('spe', '')

                # extract drop rate
                dropRate = extractSingle(RegexEnum.REGEX_DROP_CHANGE, html)

                # extract item on boss
                if (bool(dropRate)):
                    item.dropRate = dropRate
                    locationId = extractSingle(RegexEnum.REGEX_LOCATION_ID,
                                               html)
                    item.location = extractSingle(
                        RegexEnum.REGEX_LOCATION_NAME.replace(
                            '{locationId}', locationId), html)
                    item.method = TypeEnum.METHOD_KILL.replace(
                        '{targetName}',
                        extractSingle(RegexEnum.REGEX_LOOT_PNJ_NAME, html))
                    item.type = TypeEnum.BY_KILLING

                # No drop rate, the item could be loot in several boss in the instance or in quest or world drop or craft by the player or in treasur
                else:
                    # extract maybe several location
                    locationIds = extractAll(RegexEnum.REGEX_LOCATION_ID, html)

                    # item is contain in a treasure
                    if (bool(extractSingle(RegexEnum.REGEX_IS_CONTAINED,
                                           html))):
                        item.type = TypeEnum.TYPE_BY_TREASURE
                        item.location = extractSingle(
                            RegexEnum.REGEX_LOCATION_NAME.replace(
                                '{locationId}', locationIds[0]), html)
                        item.method = extractSingle(
                            RegexEnum.REGEX_TREASURE_LOCATION.replace(
                                '{locationId}', locationIds[0]), html)
                        item.dropRate = TypeEnum.EMPTY

                    # item have a location
                    elif (bool(locationIds)):
                        locationIds = distinct(locationIds)

                        # item on several boss in the same instance
                        if (len(locationIds) == 1):
                            item.location = extractSingle(
                                RegexEnum.REGEX_LOCATION_NAME.replace(
                                    '{locationId}', locationIds[0]), html)
                            item.type = TypeEnum.BY_KILLING
                            item.method = TypeEnum.METHOD_SEVERAL_BOSSESS
                            item.dropRate = TypeEnum.EMPTY

                        # world drop
                        else:
                            item.location = TypeEnum.TYPE_BY_WORLD_EVENT
                            item.type = TypeEnum.BY_KILLING
                            item.method = TypeEnum.EMPTY
                            item.dropRate = TypeEnum.EMPTY
                    else:
                        profession = extractSingle(RegexEnum.REGEX_PROFESSION,
                                                   html)

                        # item by craft
                        if (bool(profession)):
                            item.type = TypeEnum.TYPE_BY_PROFESSION.replace(
                                '{professionName}', profession.capitalize())
                            item.dropRate = TypeEnum.EMPTY
                            item.method = TypeEnum.EMPTY

                            craftLocation = extractAll(
                                RegexEnum.REGEX_CRAFT_LOCATION.replace(
                                    '{itemName}', str(item.name)), html)
                            if (craftLocation):
                                # item have a sub locationz
                                if (craftLocation
                                        and bool(craftLocation[0][4])):
                                    item.location = craftLocation[0][4]
                                else:
                                    item.location = extractSingle(
                                        RegexEnum.REGEX_LOCATION_NAME.replace(
                                            '{locationId}',
                                            str(craftLocation[0][7])), html)

                        # item by quest
                        else:

                            item.type = TypeEnum.TYPE_BY_QUEST
                            item.dropRate = TypeEnum.EMPTY

                            # extract quest location id  id by group (2 group)
                            locationIds = []
                            extractLocations = extractAll(
                                RegexEnum.REGEX_QUEST_LOCATION_ID, html)
                            if (bool(extractLocations)):
                                for locationId in extractLocations:
                                    if (locationId[0] == ''):
                                        locationIds.append(locationId[1])
                                    else:
                                        locationIds.append(locationId[0])

                                # extract quest location name
                                locations = []
                                for locationId in locationIds:
                                    location = extractSingle(
                                        RegexEnum.REGEX_LOCATION_NAME.replace(
                                            '{locationId}', str(locationId)),
                                        html)
                                    if (bool(location)):
                                        locations.append(location)

                                if (len(locations) > 1):
                                    item.location = ', '.join(locations)
                                else:
                                    item.location = locations[0]

                            # extract method (quest name)
                            extractMethods = extractAll(
                                RegexEnum.REGEX_QUEST_NAME, html)
                            if (bool(extractMethods)):
                                methods = distinct(extractMethods)
                                if (len(methods) > 1):
                                    item.method = ', '.join(methods)
                                else:
                                    item.method = methods[0]

                page.metadata['items'].append(item)
    return pages