add keywords json
parent
06f6ee9646
commit
93d715a0f6
File diff suppressed because it is too large
Load Diff
24
scrapper.py
24
scrapper.py
|
@ -12,13 +12,17 @@ import re
|
||||||
with open("marketplaces.json", "r", encoding="utf-8") as f:
|
with open("marketplaces.json", "r", encoding="utf-8") as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
|
|
||||||
|
with open("keywords.json", "r", encoding="utf-8") as f:
|
||||||
|
keywords = json.load(f)
|
||||||
|
|
||||||
with open("cookies.json", "r", encoding="utf-8") as f:
|
with open("cookies.json", "r", encoding="utf-8") as f:
|
||||||
cookies_ref = json.load(f)
|
cookies_ref = json.load(f)
|
||||||
|
|
||||||
# Or if it's a Python dict already:
|
# Or if it's a Python dict already:
|
||||||
marketplaces = data["marketplaces"]
|
marketplaces = data["marketplaces"]
|
||||||
|
|
||||||
BASE_PATH= '/mnt/AmazonReports/Amazon/keyword_ranking'
|
#BASE_PATH= '/mnt/AmazonReports/Amazon/keyword_ranking'
|
||||||
|
BASE_PATH= 'data'
|
||||||
MAX_PAGE = 10
|
MAX_PAGE = 10
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,14 +153,16 @@ def get_amazon_ranks(url, marketplace, ratingPrefix, keyword, page, count):
|
||||||
|
|
||||||
|
|
||||||
driver = get_driver()
|
driver = get_driver()
|
||||||
for marketplace, details in marketplaces.items():
|
|
||||||
url = details['url']
|
for keyword in keywords:
|
||||||
ratingPrefix = details['ratingPrefix']
|
for marketplace, details in marketplaces.items():
|
||||||
count =1
|
url = details['url']
|
||||||
for i in range(1, MAX_PAGE):
|
ratingPrefix = details['ratingPrefix']
|
||||||
count = get_amazon_ranks(url, marketplace, ratingPrefix, 'comforter navy queen', i, count)
|
count =1
|
||||||
if count == -1:
|
for i in range(1, MAX_PAGE):
|
||||||
break
|
count = get_amazon_ranks(url, marketplace, ratingPrefix, keyword, i, count)
|
||||||
|
if count == -1:
|
||||||
|
break
|
||||||
sleep(3)
|
sleep(3)
|
||||||
driver.quit()
|
driver.quit()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue