fname = "categories/"+category.replace('/','-')

        # check to make sure you haven't already 
        # done this so you don't spend money
        if os.path.isfile(fname):
            print fname, "already exists"
            continue        


        i = 1
        with open(fname,"w") as f:
            doit = True
            while doit:
                try:
                    print "alexa request",category,i
                    # make a query. 
                    tree = api.category_listings(category, Recursive=True, Start=i)
                    
                    # parse the query so that you only get the urls
                    for item in tree.findall("//{%s}DataUrl" % api.NS_PREFIXES["awis"]):
                        f.write(item.text+'\n')

                    # if there are no more queries to be made then quit.
                    if len(tree.findall("//{%s}DataUrl" % api.NS_PREFIXES["awis"])) < 100:
                        doit = False
                        break
                    i += 100
                except Exception as e:
                    doit = False
Beispiel #2
0
        # check to make sure you haven't already
        # done this so you don't spend money
        if os.path.isfile(fname):
            print fname, "already exists"
            continue

        i = 1
        with open(fname, "w") as f:
            doit = True
            while doit:
                try:
                    print "alexa request", category, i
                    # make a query.
                    tree = api.category_listings(category,
                                                 Recursive=True,
                                                 Start=i)

                    # parse the query so that you only get the urls
                    for item in tree.findall("//{%s}DataUrl" %
                                             api.NS_PREFIXES["awis"]):
                        f.write(item.text + '\n')

                    # if there are no more queries to be made then quit.
                    if len(
                            tree.findall("//{%s}DataUrl" %
                                         api.NS_PREFIXES["awis"])) < 100:
                        doit = False
                        break
                    i += 100
                except Exception as e:
Beispiel #3
0
def test_unicode():
    api = AwisApi(os.environ["AWS_ACCESS_ID"], os.environ["AWS_SECRET_ACCESS_KEY"])
    tree = api.category_listings("Top/World/Dansk/Børn_og_unge/Kultur")
    listings = tree.findall(".//awis:Listing", AwisApi.NS_PREFIXES)

    assert len(listings) > 0