BeautifulSoup find_all limited to 50 results?

I am trying to get results on 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 returned more than 50 results. Any suggestions?

thank

+4
source share
3 answers

Try using the query css-selector.

scores = soup.select('#scoretable > tr[style*="height:18px;"]')
print(len(scores))

>>>613
+1
source

Try it -

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
+2
source

'height: 18px; .

scores = soup.find_all('tr', {'style': 'height:18px;'}, limit=None)

"height:18px;", 50 . height:18px; , 613 .

You need to edit this line to find lines that have height: 18px; style (and other meanings). You can pass the regex as an argument to the style as per the documentation , maybe something like this:

soup.find_all('tr', style = re.compile('height:18px'), limit=None)
+1
source

Source: https://habr.com/ru/post/1670909/


All Articles