python – BeautifulSoup find_all限制为50个结果?
作者:互联网
我正在尝试使用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
我读了之前的解决方案:Beautiful Soup findAll doen’t find them all
我尝试了html.parser,lxml和html5lib,但没有一个返回超过50个结果.有什么建议?
谢谢
解决方法:
尝试使用css-selector查询.
scores = soup.select('#scoretable > tr[style*="height:18px;"]')
print(len(scores))
>>>613
标签:python,lxml,beautifulsoup,html5lib 来源: https://codeday.me/bug/20190522/1154449.html