【发布时间】:2020-12-13 01:04:30
【问题描述】:
我希望使用 Beautiful Soup 从this 页面提取所有品牌。到目前为止,我的程序是:
from selenium.webdriver import Firefox
from selenium.webdriver.firefox.options import Options
from bs4 import BeautifulSoup
def main():
opts = Options()
opts.headless = True
assert opts.headless # Operating in headless mode
browser = Firefox(options=opts)
browser.get('https://neighborhoodgoods.com/pages/brands')
html = browser.page_source
soup = BeautifulSoup(html, 'html.parser')
brand = []
for tag in soup.find('table'):
brand.append(tag.contents.text)
print(brand)
browser.close()
print('This program is terminated.')
我正在努力找出要使用的正确标签,因为数据嵌套在 tr/td 中。有什么建议吗?非常感谢!
【问题讨论】:
-
预期输出是什么?
-
您还想要
brandlistRight类下的数据(描述)吗?还是只是公司名称?
标签: python html beautifulsoup