Example #1
0
def searchSteam(request):

    # http://store.steampowered.com/search/suggest?term=searchTerms&f=games
    if "keywords" in request.GET:
        keywords = request.GET.get("keywords")

        # get steam results
        searchList = Steam.searchSteam(keywords)

        return HttpResponse(json.dumps(searchList), mimetype="application/json")

    else:
        return HttpResponse("missing_param", mimetype="text/plain", status="500")
Example #2
0
def searchSteam(request):

    # http://store.steampowered.com/search/suggest?term=searchTerms&f=games
    if 'keywords' in request.GET:
        keywords = request.GET.get('keywords')

        # get steam results
        searchList = Steam.searchSteam(keywords)

        return HttpResponse(json.dumps(searchList), mimetype='application/json')

    else:
        return HttpResponse('missing_param', mimetype='text/plain', status='500')
def updateSteamPageDeferred():
    # get items
    items = Items.query().fetch()

    # iterate items
    for item in items:

        # steam price URL not found
        if (item.item_steamPriceURL == None or item.item_steamPriceURL.strip() == ''):

            # search steam
            searchList = Steam.searchSteam(item.item_name)

            # add all names to array and item names to dictionary by name
            nameList = []
            searchDictionary = {}

            for steamItem in searchList:
                nameList.append(steamItem['name'])
                searchDictionary[steamItem['name']] = steamItem

            # get closest matches
            closestMatches = difflib.get_close_matches(item.item_name, nameList, 1)

            # match found
            if (len(closestMatches) != 0):
                firstMatch = closestMatches[0]

                logging.info('------ UPDATE STEAM PAGE v2 -------')
                logging.info(item.item_name)
                logging.info(searchDictionary[firstMatch]['page'])

                # update steam price info
                item.item_steamPriceURL = searchDictionary[firstMatch]['page']
                item.item_steamPrice = searchDictionary[firstMatch]['price']
                item.put()

    return HttpResponse('success', mimetype='text/plain', status='200')