[Python] Python-Selenium: Loading the third page from bvc.com.co shows blank screen

Discussão em 'Python' iniciado por Stack, Junho 5, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to scrap some data from bvc.com.co (the Colombian Stock Exchange webpage). But always, when loading the third stock, the screen comes blank and the target expected_condition can not be executed (maybe because the page is not shown). Here is my code:

    stocks = ['https://www.bvc.com.co/renta-variable-mercado-local/cibest?tab=operaciones',
    'https://www.bvc.com.co/renta-variable-mercado-local/pfcibest?tab=operaciones',
    'https://www.bvc.com.co/renta-variable-mercado-local/bogota?tab=operaciones',
    'https://www.bvc.com.co/renta-variable-mercado-local/bhi?tab=operaciones',
    'https://www.bvc.com.co/renta-variable-mercado-local/celsia?tab=operaciones']

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

    driver = selenium.webdriver.Chrome()

    useless_frame = False

    for i in stocks:
    print(i)
    #driver = selenium.webdriver.Chrome()
    driver.get(i)

    if not useless_frame: #closing a useless frame
    bvc_frame = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, '.sc-843139d2-14.iwukQD')))
    if bvc_frame:
    bvc_frame.click()
    useless_frame = True
    time.sleep(1)

    target = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, '//*[@id="__next"]/div/div[3]/div[3]/div/div[1]/ul/li[3]')))
    driver.execute_script("arguments[0].scrollIntoView()", target)
    time.sleep(1)


    A solution (but not the best) is initializing the driver into the loop. However, this makes the Chrome app open and close for each stock, which makes the code take a longer time to finish.

    PD: the options.add_argument('--disable-blink-features=AutomationControlled') does not fix the problem.

    Continue reading...

Compartilhe esta Página