【发布时间】:2021-06-12 09:22:16
【问题描述】:
我已经搜索了特定品牌三星,对于这个数量的产品是搜索,我只是想从搜索产品的产品名称中刮掉所有的href。
enter code here
import urllib.request
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.keys import Keys
chrome_path =r'C:/Users/91940/AppData/Local/Programs/Python/Python39/Scripts/chromedriver.exe'
driver = webdriver.Chrome(executable_path=chrome_path)
driver.implicitly_wait(10)
url = "https://www.lazada.sg"
driver.get(url)
driver.maximize_window()
soup=BeautifulSoup(driver.page_source, 'lxml')
application = driver.find_element_by_id("q")
application.send_keys("Samsung")
driver.find_element_by_css_selector(".search-box__button--1oH7").click()
div = driver.find_elements_by_tag_name('div', {'class': 'GridItem__title___8JShU'})
print(len(div))
for ele in div :
print(a.get_attribute("href")
【问题讨论】:
-
您遇到了什么错误或者您还需要什么,请提及!
-
我需要a标签中搜索产品的所有链接
-
我收到错误:find_elements_by_tag_name() 接受 2 个位置参数,但给出了 3 个
标签: python pandas selenium beautifulsoup