【发布时间】:2018-10-02 13:15:42
【问题描述】:
我关注这个tutorial 是为了学习如何构建一个网络爬虫来获取工作列表。现在我正在尝试跟随另一个网站。我遇到了我不知道如何提取各个职位列表的链接的问题。
当我复制 xpath 并在我的代码中使用它时,我得到一个错误。我究竟做错了什么?
import selenium
base_url = "https://www.nationalevacaturebank.nl"
start_url = "https://www.nationalevacaturebank.nl/vacature/zoeken?query=&location=&distance=city&limit=100&sort=relevance&filters%5BcareerLevel%5D%5B%5D=Starter&filters%5BeducationLevel%5D%5B%5D=MBO"
driver = webdriver.Firefox()
elem = driver.find_element_by_xpath("//*[@id="search-results-container"]/div/div[1]/div[2]/article/job/a")
>>NoSuchElementException: Message: Unable to locate element: //*[@id="search-results-container"]/div/div[1]/div[2]/article/job/a
【问题讨论】:
-
您在搜索元素之前错过了
driver.get(start_url) -
这是我的代码。不小心在我的sn-p里删了,哎呀
标签: python python-3.x selenium xpath