各位大大晚安,以Xpath抓,一直結果none,請問有可能是哪邊出了問題呢?
[in]
!pip install selenium
from selenium import webdriver
import time
import pandas as pd
browser = webdriver.Chrome(executable_path='./chromedriver.exe')
browser.get("https://tw.mall.yahoo.com/store/%E5%B1%88%E8%87%A3%E6%B0%8FWatson
s:
time.sleep(5)
# 商品連結
# 如何找到rel Xpath ?
linkpath = '//ul[@class = "sc-eWvPqa cePswM"]/li/a'
product_links = browser.find_elements_by_xpath(linkpath)
product_link = product_links[0].get_attribute('href')
print('商品連結:',product_link)
[out]
IndexError Traceback (most recent call last)
<ipython-input-22-cb447ba73a6b> in <module>
11 linkpath = '//ul[@class = "sc-eWvPqa cePswM"]/li/a'
12 product_links = browser.find_elements_by_xpath(linkpath)