Я пытаюсь получить цены от этого сайта на несколько мониторов.Вот мой код:
def noteBooksBillgerParser(url):
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36'}
page = requests.get(url, headers=headers)
while True:
print ("test")
sleep(3)
try:
doc = html.fromstring(page.content)
XPATH_PRICE = '//div[@id="product_detail_price"]//content()'
RAW_PRICE = doc.xpath(XPATH_PRICE)
PRICE = ' '.join(''.join(RAW_PRICE).split()).strip() if RAW_PRICE else None
data = {
'PRICE': PRICE,
'URL': url,
}
return data
except Exception as e:
print
e
def ReadIDs():
# AsinList = csv.DictReader(open(os.path.join(os.path.dirname(__file__),"Asinfeed.csv")))
IDList = ['vp248qg',
'vz239he',
'vs247hr+164581'
]
extracted_data = []
for i in IDList:
url = "https://www.notebooksbilliger.de/asus+" + i
print("Processing: ", url)
extracted_data.append(noteBooksBillgerParser(url))
sleep(2)
f = open('notebooksbilliger.json', 'w')
json.dump(extracted_data, f, inde
nt=4)
Я почти уверен, что большая часть кода работает, но я не уверен, как получить Price в моей переменной XPATH_PRICE.Я думаю, что может быть ошибка.