【发布时间】:2018-07-15 02:16:04
【问题描述】:
我已经用 Beautifulsoup 尝试了 urllib。通过使用带有相关标签的soup.select,我总是得到一个空的结果。 我是 Python 新手。非常感谢您提前提供的帮助!
附上代码供您参考。
import urllib.request, urllib.parse, urllib.error
from bs4 import BeautifulSoup
import pandas as pd
url="https://www.walmart.com/ip/Twin-Pack-Kellogg-s-Frosted-Mini-Wheats-Breakfast-Cereal-48-Oz/940504168"
html = urllib.request.urlopen(url).read()
soup = BeautifulSoup(html, "html.parser")
name_box = soup.select('div.nutrition-facts-all-facts-servingSize.div.span')
print(name_box)
【问题讨论】:
-
你试过
soup.findAll() -
是的,我做到了。谢谢!
-
发布你的一些代码会很好,这样我们就可以看到哪里出了问题
-
我上传了一些我测试过的代码。非常感谢您提前提供的帮助!
标签: python beautifulsoup urllib