0
Hello! I started studying Python and I’m trying to make web scraping on the OLX site. I can search and filter. But how can I make a loop for him to click on all the ads so I can pick up the phones?
my script so far:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
class Olx:
 def __init__(self, imovel):
    self.imovel = imovel
    self.driver = webdriver.Firefox(executable_path=r'C:\Users\Fabio\Desktop\robo\geckodriver.exe')
 def procura(self):
    driver = self.driver
    driver.get('https://www.olx.com.br')
    time.sleep(2)
    procura_element = driver.find_element_by_xpath("//input[@name='q']")
    procura_element.clear()
    procura_element.send_keys(self.imovel)
    procura_element.send_keys(Keys.RETURN)
    time.sleep(2)
    self.clicaregiao()
 def clicaregiao(self):
    drive = self.driver
    drive.get('https://sp.olx.com.br/?q=imovel')
    drive.find_element_by_xpath ('/html/body/div[1]/div/div[1]/div[5]/div/div[2]/div[1]/div[2]/div/ul[1]/li[2]/a').click()
    time.sleep(3)
    drive.find_element_by_class_name('g5f41w-3 bGwyNR').click()
Thank you!!! helped a lot!
– Fábio Siqueira