【发布时间】:2021-09-10 13:41:53
【问题描述】:
我试图使用 Python 上的 BeautifulSoup 从网站“https://www.geappliances.com/ge-appliances/kitchen/ranges/”中抓取一些数据,该网站有一些产品。
import unittest, time, random
from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager
from bs4 import BeautifulSoup
import pandas as pd
links = []
browser = webdriver.Firefox(executable_path="C:\\Users\\drivers\\geckodriver\\win64\\v0.29.1\\geckodriver.exe")
browser.get("https://www.geappliances.com/ge-appliances/kitchen/ranges/")
content = browser.page_source
soup = BeautifulSoup(content, "html.parser")
for main in soup.findAll('li', attrs = {'class' : 'product'}):
name=main.find('a', href=True)
if (name != ''):
links.append((name.get('href')).strip())
print("Got links : ", len(links))
exit()
在输出中我得到:- 获得链接:0
我打印了汤,发现汤里没有这部分。我一直试图解决这个问题无济于事。 难道我做错了什么?任何建议表示赞赏。谢谢。
【问题讨论】:
标签: python beautifulsoup