【发布时间】:2021-03-04 08:41:08
【问题描述】:
因为我想从https://www.nike.com/gb/t/air-max-viva-shoe-ZQTSV8/DB5268-003 获取描述文本 但输出时不打印。
import requests
from bs4 import BeautifulSoup
import re
url ="https://www.nike.com/gb/t/air-max-viva-shoe-ZQTSV8/DB5268-003"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'lxml')
headline1 = soup.find('h3', class_ = 'epdp-headline-md headline-1')
headline = soup.find('div',class_ = 'epdp-headline-sm body-1')
print(headline1,headline)
【问题讨论】:
-
如果你看到[页面来源](view-source:nike.com/gb/t/air-max-viva-shoe-ZQTSV8/DB5268-003),没有
epdp-headline-md或epdp-headline-sm的类,这就是你得到None的原因. -
http https://www.nike.com/gb/t/air-max-viva-shoe-ZQTSV8/DB5268-003 | grep epdp-headline没有给我任何输出,所以看起来你正在寻找的数据不在那里。它可能是动态内容,稍后通过 JavaScript 下载。 -
那么我如何获取这些数据?
-
#brunns 有没有办法获取数据??
标签: python beautifulsoup python-requests