Selenium Bug in result

0

I'm trying to create a robbery that takes all the phone information from Brazilian postal agencies, it's two dependent dropdowns that when selecting state and municipality, the agencies appear in place. My code so far is:

from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.select import Select
import time                 

chrome_path = r"C:\Users\Gustavo\Desktop\geckodriver\chromedriver.exe"

driver = webdriver.Chrome(chrome_path)
lista_x = []
driver.get("http://www2.correios.com.br/sistemas/agencias/")
WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, 'municipioAgencia')))
driver.maximize_window()


estado_select = Select(driver.find_element_by_id('estadoAgencia'))
municipio_select = Select(driver.find_element_by_id('municipioAgencia'))
#def get_info():
#   info_select = Select(driver.find_element_by_id('bullet ageNomeEvent nomeAgencia'))
#   for i in range(len(info_select))

for opt in estado_select.options:
    print(opt.get_attribute('innerHTML'))
    opt.click()  
    time.sleep( 5 )
    for opt2 in municipio_select.options:
        print(opt.get_attribute('innerHTML'))
        opt2.click()
        time.sleep(0.2)

However, when it arrives in Bahia, the municipalities begin to repeat themselves, what may be going wrong?

    
asked by anonymous 09.07.2018 / 22:18

0 answers