安装chrome driver(14)

 

 根据自己的chrome的版本,下载相应的版本:

安装chrome driver(14)

 

 软件测试:

import time

from selenium import webdriver
from scrapy import Selector
from selenium.common.exceptions import NoSuchElementException

#键入自己的实际安装路径
browser = webdriver.Chrome(executable_path="D:/google-chrome/chromedriver.exe")
browser.get("https://item.jd.com/7652013.html")

try:
    click_ele = browser.find_element_by_xpath("//li[@clstag='shangpin|keycount|product|shangpinpingjia_1']")
    click_ele.click()
except NoSuchElementException as e:
    pass

sel = Selector(text=browser.page_source)
print(sel.xpath("//span[@class='price J-p-7652013']/text()").extract_first())
browser.close()

 

相关文章:

  • 2021-09-27
  • 2021-09-18
  • 2021-12-10
  • 2021-11-25
  • 2021-09-18
  • 2021-07-01
  • 2022-01-25
  • 2022-12-23
猜你喜欢
  • 2021-10-10
  • 2021-11-07
  • 2021-07-10
  • 2021-09-13
  • 2021-10-21
  • 2021-12-25
  • 2022-12-23
相关资源
相似解决方案