Comparando o preço de um mesmo produto a cada minuto e me notificando quando o valor cair 50%. Usei um While >= mas está retornando um erro indicando que não pode usar >= entre str e int. Ele acaba retornando o preço como uma string.
Vou mostrar o código como está:
from selenium import webdriver
from time import sleep
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--hedless')
driver = webdriver.Chrome()
driver.get('https://www.magazineluiza.com.br/ssd-480gb-kingston-sata-rev-3-0-leituras-500mb-s-e-gravacoes-450mb-s-a400/p/220920100/in/ssdi/')
sleep(3)
produto = driver.find_element_by_xpath('/html/body/div[3]/div[5]/div[1]/div[2]/h1').text
preçoatual = driver.find_element_by_xpath('/html/body/div[3]/div[5]/div[1]/div[3]/div[2]/div[4]/div/div[2]/div/span[2]').text
preçoalvo = 300
while preçoatual >= preçoalvo:
print(preçoatual)
sleep(1)
print('preço alvo atingido')
____________________________________________________________________________
Código alterado após as sugestões do amigo:
from selenium import webdriver
from time import sleep
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--hedless')
driver = webdriver.Chrome()
driver.get('https://www.magazineluiza.com.br/ssd-480gb-kingston-sata-rev-3-0-leituras-500mb-s-e-gravacoes-450mb-s-a400/p/220920100/in/ssdi/')
sleep(3)
produto = driver.find_element_by_class_name('header-product__title').text
preçoatual = driver.find_element_by_class_name('price-template__text').text
preçoatual = preçoatual.replace(',', '.')
preçoatual = float(preçoatual)
preçoalvo = 300
print(produto)
while preçoatual > preçoalvo:
print(preçoatual)
driver.get('https://www.magazineluiza.com.br/ssd-480gb-kingston-sata-rev-3-0-leituras-500mb-s-e-gravacoes-450mb-s-a400/p/220920100/in/ssdi/')
sleep(3)
produto = driver.find_element_by_class_name('header-product__title').text
preçoatual = driver.find_element_by_class_name('price-template__text').text
preçoatual = preçoatual.replace(',', '.')
preçoatual = float(preçoatual)
sleep(5)
print('preço alvo atingido')