我需要src-0,src-1,src-2…附近的链接src-59我怎样才能修复编码?谢谢
!pip install selenium
from selenium import webdriver
import time
import pandas as pd
browser = webdriver.Chrome(executable_path='./chromedriver.exe')
browser.implicitly_wait(5)
browser.get("https://tw.mall.yahoo.com/store/%E5%B1%88%E8%87%A3%E6%B0%8FWatsons:watsons")
# 商品連結
linkPath = "//ul[@class='gridList']/li/a"
product_links = browser.find_elements_by_xpath(linkPath)
print(product_links)发布于 2021-11-22 01:37:51
您正在使用的xpath没有突出显示DOM中的任何元素。
像下面这样尝试,希望这些就是你想要提取的链接。
# Imports Required
from selenium import webdriver
from selenium.webdriver.common.by import By
driver.get("https://tw.mall.yahoo.com/store/%E5%B1%88%E8%87%A3%E6%B0%8FWatsons:watsons")
links = driver.find_elements(By.XPATH,"//section[contains(@class,'MainListing__StoreBoothWrap')]/div/div/div/ul/li/a")
print(len(links))
for link in links:
print(link.get_attribute("href"))60
https://tw.mall.yahoo.com/item/p0330231079018
https://tw.mall.yahoo.com/item/p0330221397264
https://tw.mall.yahoo.com/item/p0330201617111
...https://stackoverflow.com/questions/70059616
复制相似问题