[Python] Scraping a website that updates data constantly and irregularly

Discussão em 'Python' iniciado por Stack, Março 1, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to scrape a web application to get values of the table . How do I scrape the table every time new values are added to the table or otherwise how can I scrape the website? The website

    My basic code only lets me scrape manually resulting to many values not being scraped. Also,

    driver.find_elements_by_xpath


    does not return anything but

    WebDriverWait(driver, 100).until(EC.presence_of_all_elements_located()


    works.

    Below is my code

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

    website = "https://play.pakakumi.com/"
    path = r'D:\chromedriver_win32\chromedriver.exe'
    driver = webdriver.Chrome(path)
    driver.get(website)

    page = driver.page_source
    soup = BeautifulSoup(page, 'html.parser')


    '''
    k =driver.find_elements_by_xpath('/html/body/div/div[2]/div[2]/div/div[1]/div/div[3]/div/div[2]/div/table/tbody/tr/td[1]')


    for item in k:
    print(item.text)
    '''
    foo = WebDriverWait(driver, 100).until(EC.presence_of_all_elements_located((By.XPATH, '/html/body/div/div[2]/div[2]/div/div[1]/div/div[3]/div/div[2]/div/table/tbody/tr/td[1]')))
    for b in foo:
    print(b.text)
    #print(foo)

    Continue reading...

Compartilhe esta Página