Python Forum

Full Version: Beautiful soup won't find value even with CSS path copied.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everyone,

I'm very new to Python, my first project is writing a program to report a figure from a matched betting site, using ATBS as a guide so far. When selecting the info to parse, i get a blank response within the square brackets like so:

>>> soup.select('#tableBase > tbody > tr:nth-child(1) > td.rating.sorting_1')
[]
Any ideas why this is happening and how I can get that number selected?
here is the html from the table: https://pastebin.com/QXLPahsy

Thanks in advance!
Could you supply the URL, much easier to examine the HTML from the actual site.
getting to the specific url requires login unfortunately.
My guess would be that you're getting the html from your browser's developer tools, and the tbody is not actually in the source, but inserted by the browser.
But it's only a guess, since we can't see the actual page.
Its not sorting_1 but class="rating sorting\_1"
If i do test with your html.
from bs4 import BeautifulSoup

soup = BeautifulSoup(your_html, 'lxml')
td_sort = soup.find('td', class_="rating sorting\_1")
print(td_sort)
print(td_sort.text)
Output:
<td class="rating sorting\_1" style="color: rgb(0, 0, 0);">98.35</td> 98.35