1

列表 Li 应该有 116 个元素,但它有 0 个元素

import requests
from bs4 import BeautifulSoup
url='https://www.profile.nl/zoekresultaten/banden?size_width=205&size_height=60&size_inch=16'
profile= requests.get(url)
if profile.ok:

    soup = BeautifulSoup(profile.text,'lxml')

    Li= (soup.body).findAll("div", attrs={"class": "row xs-ptb-1"})
    print(len(Li))
4

1 回答 1

4

它是从您可以在网络选项卡中看到的另一个端点动态提取的。对于浏览器,此附加请求用于更新页面。对于请求,这不会发生;因此,您将请求直接发送到该其他端点以获取信息。

import requests

r = requests.get('https://www.profile.nl/tyres_search.json?locale=nl&size_width=205&size_height=60&size_inch=16.0').json()
print(r['products'])
于 2021-07-11T05:46:53.987 回答