コード例 #1
0
        """select c.display_name, c.id, count(*) from clothes.amazon_products p, clothes.amazon_categories c
                         where c.id=p.browse_node_id and p.status='active' group by c.display_name, c.id order by 3 desc"""
    )
    return res['data']


if __name__ == "__main__":
    cats = [
        "Women's Dresses", "Men's T-Shirts", "Men's Shirts", "Men's Jackets",
        "Women's Tops", "Women's Everyday Bras", "Women's T-Shirts",
        "Women's Blouses & Shirts"
    ]

    pgcs = PGConnector({
        "host": "quackdb.cozdd0etxhab.eu-west-1.rds.amazonaws.com",
        "user": "******",
        "password": "******",
        "dbname": "uk"
    })
    res = pgcs.select(
        """select c.display_name, c.id, count(*) from clothes.amazon_products p, clothes.amazon_categories c
                         where c.id=p.browse_node_id and p.status='active' group by c.display_name, c.id order by 3 desc"""
    )

    print res
    for r in res['data']:
        if r[0] in cats and r[2] > 2000:
            print r
            products = getCategoryProducts(pgcs, r[1])
            print "%d products" % len(products)
            print "testing to see if images exist..."
            cnt = 0
コード例 #2
0
ファイル: testad.py プロジェクト: mosssimo/glass
                  'description2': details['description2'],
                  'headline': details['headline']
              },
              # Optional fields.
              'status': details['status']
          }
      }
  ]
  ads = ad_group_ad_service.mutate(operations)

  # Display results.
  for ad in ads['value']:
    print ('Ad with id \'%s\' and of type \'%s\' was added.'
           % (ad['ad']['id'], ad['ad']['Ad.Type']))


if __name__ == '__main__':
    # Initialize client object.
    adwords_client = adwords.AdWordsClient.LoadFromStorage()

    #main(adwords_client, AD_GROUP_ID)

    pgcs = PGConnector({"host":"192.168.2.76", "user":"******", "password":"******", "dbname":"backend"})
    res = pgcs.select("""select * from adwords.ad_text where id=6316943""")

    for r in res['data']:
        for i, f in enumerate(r):
            print i, f
        data = r
        details = {'status':r[7], 'finalUrls':r[15], 'displayUrl':r[9], 'description1':r[12], 'description2':r[13], 'headline':r[11]}
        add_advert(adwords_client, AD_GROUP_ID, unify(details))
コード例 #3
0
            cnt += 1


if __name__ == "__main__":
    mongoStore = MongoStore("UK")
    import cv2

    if False:
        mongoStore.getAllProducts()
    else:
        from sql import PGConnector
        from groups import getTopCategories

        pgcs = PGConnector({
            "host": "quackdb.cozdd0etxhab.eu-west-1.rds.amazonaws.com",
            "user": "******",
            "password": "******",
            "dbname": "uk"
        })
        cats = getTopCategories(pgcs)
        catlists = {}
        fetch = False

        for c in cats:
            if c[2] > 1000:
                cnt = 0
                cat = {'name': c[0], 'id': c[1], 'images': []}
                print c
                for p in mongoStore.mongodb.amazon_products.find({
                        'BrowseNodes.0.BrowseNodeId':
                        c[1]
                }).batch_size(100):
コード例 #4
0
ファイル: groups.py プロジェクト: mosssimo/glass
def getCategoryProducts(pgc, catId):
    res = pgc.select("""select asin from clothes.amazon_products where browse_node_id=%s and status='active'""", (catId,))
    products = [r[0] for r in res['data']]
    return products

def getTopCategories(pgc):
    res = pgc.select("""select c.display_name, c.id, count(*) from clothes.amazon_products p, clothes.amazon_categories c
                         where c.id=p.browse_node_id and p.status='active' group by c.display_name, c.id order by 3 desc""")
    return res['data']

if __name__=="__main__":
    cats=["Women's Dresses","Men's T-Shirts","Men's Shirts","Men's Jackets","Women's Tops",
          "Women's Everyday Bras","Women's T-Shirts","Women's Blouses & Shirts"]

    pgcs = PGConnector({"host":"quackdb.cozdd0etxhab.eu-west-1.rds.amazonaws.com", "user":"******", "password":"******", "dbname":"uk"})
    res = pgcs.select("""select c.display_name, c.id, count(*) from clothes.amazon_products p, clothes.amazon_categories c
                         where c.id=p.browse_node_id and p.status='active' group by c.display_name, c.id order by 3 desc""")

    print res
    for r in res['data']:
        if r[0] in cats and r[2]>2000:
            print r
            products = getCategoryProducts(pgcs, r[1])
            print "%d products" % len(products)
            print "testing to see if images exist..."
            cnt=0
            for p in products:
                try:
                    f = open("/home/simon/data/palovito/images/"+p['asin']+".jpg")
                    cnt+=1
コード例 #5
0
    # Display results.
    for ad in ads['value']:
        print('Ad with id \'%s\' and of type \'%s\' was added.' %
              (ad['ad']['id'], ad['ad']['Ad.Type']))


if __name__ == '__main__':
    # Initialize client object.
    adwords_client = adwords.AdWordsClient.LoadFromStorage()

    #main(adwords_client, AD_GROUP_ID)

    pgcs = PGConnector({
        "host": "192.168.2.76",
        "user": "******",
        "password": "******",
        "dbname": "backend"
    })
    res = pgcs.select("""select * from adwords.ad_text where id=6316943""")

    for r in res['data']:
        for i, f in enumerate(r):
            print i, f
        data = r
        details = {
            'status': r[7],
            'finalUrls': r[15],
            'displayUrl': r[9],
            'description1': r[12],
            'description2': r[13],
            'headline': r[11]