Quantcast WoWInterface - View Single Post - Database crawler
View Single Post
03-16-14, 05:39 AM   #11
xxauroraxx
A Murloc Raider
Join Date: Mar 2014
Posts: 5
This will look for all items with a specific slot, and stat (such as intellect, or increased spell damage).

Code:
import pickle

myFile = open('itemdatabase.db', 'r')
myDB = pickle.load(myFile)
myFile.close

myDir = "D:/_itemsearches/"

while True:

    myItems = []
    
    count = 0
    slot = raw_input('Enter slot to look for: ')
    for k,v in myDB.iteritems():
        for x in v:
            if slot.lower() in x.lower():
                count += 1
                myItems.append(k)
    if count < 1:
        print '\tNo items found with a slot type of "%s"'%slot
    else:
                
        count = 0
        stat = raw_input('Enter stat to look for: ')
        
        myFile = "%s_%s-with-%s.txt"%(myDir,slot.lower(),stat.lower())
        fileIO = open(myFile, 'w')
        fileIO.write('\n')
        fileIO.close
        
        fileIO = open(myFile, 'a')
        for x in myItems:
            for y in myDB[x]:
                newStat = 'blank'
                if stat.lower() in ['agility', 'stamina', 'intellect', 'spirit', 'agility']:                
                    if stat.lower() in y.lower() and '+' in y:
                        count += 1                    
                        newStat = y.split('+')[1].split(' ')[0] + ' ' + stat.lower()
                else:
                    if stat.lower() in y.lower():
                        newStat = y
                        #print "%s : %s"%(x, newStat)
                if newStat != 'blank':
                    fileIO.write("%s\n\t%s\n"%(x, newStat))
                    
                    
        if count < 1:
            print "\tNo %s items found with %s"%(slot, stat)
        fileIO.close 
        
        fileIO = open(myFile, 'r')
        for x in fileIO:
            print x
        fileIO.close
This finds every different stat on an item. If the item has set bonuses, other items part of the set will not display as a stat.

Code:
import pickle

myFile = open('itemdatabase.db', 'r')
myDB = pickle.load(myFile)
myFile.close

myDir = "D:/_itemsearches/"
myFile = "%squeryable-stats.txt"%myDir
fileIO = open(myFile, 'w')
fileIO.write('\n')
fileIO.close

allStats = []
allItems = []
for k,v in myDB.iteritems():
    allItems.append(k)
for k,v in myDB.iteritems():
    for x in v:
        if x not in allStats and x not in allItems:
            allStats.append(x)

fileIO = open(myFile, 'a')            
for x in allStats:
    fileIO.write(x)
    fileIO.write('\n')
    print x
    print '\n'
fileIO.close
In both examples, we first create the file, and make sure it is empty. Then, we append all data.
  Reply With Quote