Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Python Beautiful Soup can't find table

Status
Not open for further replies.

CarHelpo

Programmer
Oct 29, 2021
1
UA
I'm having issue with scraping my site. I'm trying to access table but can't seem to target the correct div/table. I'm trying to capture the table and bring it into a dataframe using pandas.

I've tried using soup.find and soup.find_all to find a all the tables but when I search the results I do not see the ID of the table I am looking for. See below.

Python:
x = soup.find("table", id="team-stats-per_game")

import csv, time, sys, math
import numpy as np
import pandas as pd
import requests 
from bs4 import BeautifulSoup
import urllib.request


#NBA season
year = 2019

# URL page we will scraping
url = "[URL unfurl="true"]https://carhelpo.com/best-budget-pressure-washer/".format(year)[/URL]

# Basketball reference URL
html = urlopen(url)
soup = BeautifulSoup(html,'lxml')

x = soup.find("table", id="team-stats-per_game")
print(x)


Result:

None
maybe something wrong with line url = " ?
I expect the output to list the table elements, specifically tr and th tags to target and bring into a pandas df.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top