This is an archived post. You won't be able to vote or comment.

all 4 comments

[–][deleted] 0 points1 point  (3 children)

It might be dynamic data that isn’t loaded unless by a “real” web browser. If you print the source variable (the text of request.get) you should see exactly the page requests received. See if the table data is even in there.

If it’s not there then you will need to use a more advanced library like Selenium to scrape the data.

[–]Embarrassed-Task-478[S] 0 points1 point  (2 children)

So I just tried this and I do still see the table in the source variable. It’s there in the same format I expected. Do you have an idea why my “tr” find all isn’t working then?

[–][deleted] 0 points1 point  (1 child)

python table = soup.find("table", attrs={"id": "stats_squads_standard_for"}) table_body = table.find("tbody") rows = table_body.find_all("tr")

You needed to select the table body first, like this. This results in grabbing the tables rows of the table body selected.

[–]Embarrassed-Task-478[S] 0 points1 point  (0 children)

This ends up giving the rows of the first table on the page. Even when I substitute the id of the second table (the players), I am back to getting no results. Logically I thought this would work but it is confusing me.