擅长:python、mysql、java
<p>这将使用选择而不是查找</p>
<pre><code>import requests
from bs4 import BeautifulSoup
url ="https://www.nike.com/gb/t/air-max-viva-shoe-ZQTSV8/DB5268-003"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'lxml')
description = soup.select('div.description-preview>p')
color = soup.select('div.description-preview>ul>li:nth-of-type(1)')
style = soup.select('div.description-preview>ul>li:nth-of-type(2)')
print(description[0].text)
print(color[0].text)
print(style[0].text)
</code></pre>