Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium 硒元素没有例外_Selenium_Error Handling_Selenium Chromedriver - Fatal编程技术网

Selenium 硒元素没有例外

Selenium 硒元素没有例外,selenium,error-handling,selenium-chromedriver,Selenium,Error Handling,Selenium Chromedriver,我正试图使用以下方法来获取Glassdoor评论: 但我得到了错误,不知道如何克服它。请帮忙 在Windows 10和Chrome 77上 2019-09-11 08:48:58961信息377:main.py(1824)-配置浏览器 DevTools listening on ws://127.0.0.1:#####/devtools/browser/cccb51a6-3dc2-4f06-90db-################ 2019-09-11 08:49:03,942 INFO

我正试图使用以下方法来获取Glassdoor评论:

但我得到了错误,不知道如何克服它。请帮忙

在Windows 10和Chrome 77上

2019-09-11 08:48:58961信息377:main.py(1824)-配置浏览器

DevTools listening on ws://127.0.0.1:#####/devtools/browser/cccb51a6-3dc2-4f06-90db-################

2019-09-11 08:49:03,942 INFO 419    :main.py(1824) - Scraping up to 1000 reviews.
2019-09-11 08:49:03,946 INFO 358    :main.py(1824) - Signing in to email@gmail.com
2019-09-11 08:49:06,541 INFO 339    :main.py(1824) - Navigating to company reviews
2019-09-11 08:49:12,674 INFO 286    :main.py(1824) - Extracting reviews from page 1
2019-09-11 08:49:12,696 INFO 291    :main.py(1824) - Found 10 reviews on page 1
2019-09-11 08:49:12,840 WARNING 126    :main.py(1824) - Failed to scrape employee_title
Traceback (most recent call last):
  File "main.py", line 461, in <module>
    main()
  File "main.py", line 441, in main
    reviews_df = extract_from_page()
  File "main.py", line 295, in extract_from_page
    data = extract_review(review)
  File "main.py", line 281, in extract_review
    res[field] = scrape(field, review, author)
  File "main.py", line 264, in scrape
    return fdict[field](review)
  File "main.py", line 156, in scrape_years
    'reviewBodyCell').find_element_by_tag_name('p')
  File "C:\Users\dvnguyen\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py", line 305, in find_element_by_tag_name
    return self.find_element(by=By.TAG_NAME, value=name)
  File "C:\Users\dvnguyen\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py", line 659, in find_element
    {"using": by, "value": value})['value']
  File "C:\Users\dvnguyen\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
    return self._parent.execute(command, params)
  File "C:\Users\dvnguyen\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\dvnguyen\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"p"}
  (Session info: headless chrome=77.0.3865.75)
DevTools在ws://127.0.0.1上侦听:######/DevTools/browser/cccb51a6-3dc2-4f06-90db-################
2019-09-11 08:49:03942信息419:main.py(1824)-最多可收集1000条评论。
2019-09-11 08:49:03946信息358:main.py(1824)-登录到email@gmail.com
2019-09-11 08:49:06541信息339:main.py(1824)-导航到公司评论
2019-09-11 08:49:12674信息286:main.py(1824)-从第1页提取评论
2019-09-11 08:49:12696信息291:main.py(1824)-在第1页找到10条评论
2019-09-11 08:49:12840警告126:main.py(1824)-未能刮取员工头衔
回溯(最近一次呼叫最后一次):
文件“main.py”,第461行,在
main()
文件“main.py”,第441行,在main中
审阅\u df=从第页()中提取
文件“main.py”,第295行,从页面中提取
数据=摘录和审查(审查)
“main.py”文件,第281行,摘录_review
res[field]=scrape(字段、评论、作者)
文件“main.py”,第264行,在scrape中
返回fdict[字段](审阅)
文件“main.py”,第156行,在scrape_年
“reviewBodyCell”)。通过标记名称(“p”)查找元素
文件“C:\Users\dvnguyen\AppData\Local\Continuum\anaconda3\lib\site packages\selenium\webdriver\remote\webelement.py”,第305行,按标签名称查找元素
返回self.find_元素(by=by.TAG_NAME,value=NAME)
文件“C:\Users\dvnguyen\AppData\Local\Continuum\anaconda3\lib\site packages\selenium\webdriver\remote\webelement.py”,第659行,在find_元素中
{“using”:by,“value”:value})[“value']
文件“C:\Users\dvnguyen\AppData\Local\Continuum\anaconda3\lib\site packages\selenium\webdriver\remote\webelement.py”,第633行,在\ u execute
返回self.\u parent.execute(命令,参数)
文件“C:\Users\dvnguyen\AppData\Local\Continuum\anaconda3\lib\site packages\selenium\webdriver\remote\webdriver.py”,执行中第321行
self.error\u handler.check\u响应(响应)
文件“C:\Users\dvnguyen\AppData\Local\Continuum\anaconda3\lib\site packages\selenium\webdriver\remote\errorhandler.py”,第242行,在检查响应中
引发异常类(消息、屏幕、堆栈跟踪)
selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:无法定位元素:{“方法”:“css选择器”,“选择器”:“p”}
(会话信息:无头镀铬=77.0.3865.75)

glassdoor可能已经改变了它的站点/布局,并且该刮板使用的方法不再有效地检测页面

也就是说,它在类类型reviewBodyCell的特定元素中寻找一个简单的“p”标记

File "main.py", line 156, in scrape_years
    'reviewBodyCell').find_element_by_tag_name('p')

快速浏览一下站点,就会发现在某些情况下,classname为reviewBodyCell的元素下没有p标记

你是如何启动网页刮板的?您的配置是什么?你能在main.py中发布代码吗?我们没有足够的信息来回答你的问题。为什么人们坚持使用硒作为网页垃圾?
File "main.py", line 156, in scrape_years
    'reviewBodyCell').find_element_by_tag_name('p')