Beispiel #1
0
def getData(id, mintime, maxtime, tries=1):
    u = url.format(id, mintime, maxtime)
    print "Try: ", tries, "Url:", u
    data = scrapper.getDataURL(u)
    try:
        x = data['result']
        return data
    except:
        if tries < 10:
            tries += 1
            time.sleep(5)
            
            return getData(id, mintime, maxtime, tries)
        else:
            print "Unable to reach:", u
            sys.exit(1)
Beispiel #2
0
def getData(id, tries=1):
    u = url.format(id)
    print "Try: ", tries, "Url:", u
    data = scrapper.getDataURL(u)
    try:
        x = data['result']['match_id']
        return data['result']
    except:
        if tries < 10:
            tries += 1
            time.sleep(5)
            
            return getData(id, tries)
        else:
            print "Unable to reach:", u
            database.updateDatabase([(sqlparse, id)])
            return None
Beispiel #3
0
import database, scrapper, sys

url = "https://api.steampowered.com/IEconDOTA2_570/GetHeroes/v0001/?key=%s"
insert = "INSERT INTO heroes(hero_id, hero_name) VALUES(%s,%s) ON DUPLICATE KEY UPDATE hero_name=hero_name"
commands = []

data = scrapper.getDataURL(url)

hero_data = data['result']['heroes']

if hero_data == None:
    sys.exit(1)

for i in hero_data:
    commands.append((insert, (i['id'], i['name'][14:])))

database.updateDatabase(commands)