I'm trying to get the results from a page using BeautifulSoup:
req_url = 'http://www.xscores.com/soccer/livescores/25-02'
request = requests.get(req_url)
content = request.content
soup = BeautifulSoup(content, "html.parser")
scores = soup.find_all('tr', {'style': 'height:18px;'}, limit=None)
print(len(scores))
>50
I read this previous solution: Beautiful Soup findAll doen't find them all and I tried html.parser, lxml and html5lib, but none of them return more than 50 results. Any suggestions?
Thank you
Beautiful Soup's find_all(~) method returns a list of all the tags or strings that match a particular criteria.
find is used for returning the result when the searched element is found on the page. find_all is used for returning all the matches after scanning the entire document.
You should use soup. find_all('div', attrs={'class': None}) the look to the div without any class attribute.
find_all() returns all the tags and strings that match your filters.
Try using css-selector
query.
scores = soup.select('#scoretable > tr[style*="height:18px;"]')
print(len(scores))
>>>613
Try this -
req_url = 'http://www.xscores.com/soccer/livescores/25-02'
request = requests.get(req_url)
html=request.text
soup = BeautifulSoup(html, "html5lib")
scoretable=soup.find('tbody',id='scoretable')
scores=scoretable.find_all('tr')
len(scores)
>617
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With