Python Forum
Beautiful soup won't find value even with CSS path copied. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Beautiful soup won't find value even with CSS path copied. (/thread-15049.html)



Beautiful soup won't find value even with CSS path copied. - AdequatelyChilled - Jan-01-2019

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!


RE: Beautiful soup won't find value even with CSS path copied. - Larz60+ - Jan-01-2019

Could you supply the URL, much easier to examine the HTML from the actual site.


RE: Beautiful soup won't find value even with CSS path copied. - AdequatelyChilled - Jan-01-2019

getting to the specific url requires login unfortunately.


RE: Beautiful soup won't find value even with CSS path copied. - stranac - Jan-01-2019

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.


RE: Beautiful soup won't find value even with CSS path copied. - snippsat - Jan-01-2019

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