[Python] python web scraping missing table rows

Discussão em 'Python' iniciado por Stack, Abril 3, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to extract a table, but i'm only getting 1 row of data. I'm trying to get the whole table

    here's the code

    url="https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-PY0220EN-SkillsNetwork/labs/project/revenue.htm"

    html_data=requests.get(url).text

    soup=BeautifulSoup(html_data,'html.parser')

    tesla_revenue=pd.DataFrame(columns=["Date","Revenue"])
    for row in soup.find_all("tbody")[1].find_all("tr"):
    col = row.find_all("td")
    date = col[0].text
    Revenue = col[1].text
    tesla_revenue=pd.concat([tesla_revenue,pd.DataFrame({"Date":[date], "Revenue":[Revenue]})], ignore_index=True)

    Continue reading...

Compartilhe esta Página