python3.6+selenium+phantomJS 网页爬虫报错NoSuchElementException问题及解决方法
来源:互联网 发布:java短信验证码第三方 编辑:程序博客网 时间:2024/04/30 07:28
错误信息:
selenium.common.exceptions.NoSuchElementException: Message: {"errorMessage":"Unable to find element with xpath '//*[@id='**']'","request":{"headers":{"Accept":"application/json",
...
}}Screenshot: available via screen
由于代码换用Chrome浏览器是正常执行的,所以个人认为原因是由于使用phantomJS后,动态JS还没有解析,没有获取到网页代码,所以才会报NoSuchElementException所以写一个方法等JS解析就行了
代码如下:
# JSdef wait(driver): elem = driver.find_element_by_tag_name('html') count = 0 while True: count +=1 if count>20: print('timeout') return time.sleep(5) try: elem == driver.find_element_by_tag_name('html') except StaleElementReferenceException: return在报错的语句前使用wait(driver)
阅读全文
0 0
- python3.6+selenium+phantomJS 网页爬虫报错NoSuchElementException问题及解决方法
- Python3 爬虫编写报错及解决方法整理
- Python+Selenium定位不到元素原因及解决方法(报:NoSuchElementException)
- selenium+phantomjs 报错备注
- 直播网站LiveTV Mining,爬虫抓取数据 python3+selenium+phantomjs
- Python3+phantomjs+selenium配置
- 基于Python3的phantomJs+Selenium动态网页爬取技术
- 爬虫利器:Selenium+PhantomJS
- phantomjs+selenium+python爬虫
- 爬虫-08-selenium & phantomjs
- console 报错:java.util.NoSuchElementException解决方法
- xpath定位报错org.openqa.selenium.NoSuchElementException:
- Python3安装PhantomJS和Selenium
- python3写爬虫程序时,遇到的问题及解决方法
- Scrapy+PhantomJS+Selenium动态爬虫
- Scrapy+PhantomJS+Selenium动态爬虫
- Scrapy+PhantomJS+Selenium动态爬虫
- 爬虫学习笔记--Selenium PhantomJS
- VC/MFC如何设置对话框背景颜色
- Elasticsearch笔记六之中文分词器及自定义分词器
- CMD命令操作MySql数据库详解
- 蚂蚁花呗提现方法及花呗怎么提现详解
- 每天一道LeetCode-----在字符串s中找到最短的包含字符串t中所有字符的子串,子串中字符顺序无要求且可以有其他字符
- python3.6+selenium+phantomJS 网页爬虫报错NoSuchElementException问题及解决方法
- Spring Cloud 配置文件切换(profiles的应用)
- 扫描二维码
- 使用java BufferedWriter写txt文本
- oncmdb部署和密码修改
- Problem B: Sequence Problem (II) : Array Practice
- 如何禁止电脑文件被复制
- java NIO selector ServerSocketChannel 例子
- ecshop 小京东 微信公众号链接打开,报错appid不能为空,错误码10012