小编因论文需要海关进口数据,利用火狐浏览器+Selenium编写了一个爬取海关数据的程序。网址上的数据原本是可以直接导出的,但是导出2019年前(包括2019年)的数据会受到服务器限制,只能导出低于1万条的数据。因此,写了一个爬虫程序对2019年海关所有商品进出口的数据进行爬取,在爬虫过程中频繁出现错误:selenium.common.exceptions.NoSuchWindowException: Message: Browsing context has been discarded。在网上查询相关资料未有解决该问题的方法,自己探索了很久,终于搞明白了为什么出现这个问题。

出现该问题的根本原因是网站上的Frame框架(frame1,frame2)中有几个并联的子框架,当我使用bro.swich_to.frame("frame1"),在frame1框架中进行元素定位,定位完成后没有使用bro.switch_to.parent_fram()回到Frame中,运行就会出现这种错误,所以大家一定要仔细检查代码是不是有遗漏bro.switch_to.parent_fram()。

按理来说,一般没有定位到Frame,使用定位元素的语句应该出现错误:未能找到elements,小编也是头一次碰到因未定位到Frame出现错误:Browsing context has been discarded。

希望小编的这次学习笔记能为大家解决同样的问题。

爬虫出现selenium.common.exceptions.NoSuchWindowException: Message: Browsing context has been discarded相关推荐

  1. 已解决 selenium.common.exceptions.NoSuchWindowException: Message: no such window

    D:\学习\Python工程\venv\Scripts\python.exe "D:\软件\PyCharm Community Edition 2019.1.3\plugins\python ...

  2. 使用selenium时遇到的报错selenium.common.exceptions.WebDriverException: Message: Service xxxxstaus:1详解及解决方法详解

    在开始之前,分享一下使用selenium常遇到的几个问题和报错: 1.首先就是版本问题的报错:selenium.common.exceptions.NoSuchWindowException: Mes ...

  3. 在进行天猫商品数据爬虫时遇到selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe'

    selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in ...

  4. 已解决 selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element 找不到元素的问题

    场景 使用selenium的find_element_by_xpath()函数报错:selenium.common.exceptions.NoSuchElementException: Message ...

  5. 已解决selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted:

    已解决python selenium模块自动化操作浏览器点击元素,抛出异常selenium.common.exceptions.ElementClickInterceptedException: Me ...

  6. 已解决selenium.common.exceptions.TimeoutException: Message:

    已解决(selenium爬虫报错)selenium.common.exceptions.TimeoutException: Message: 文章目录 报错代码 报错翻译 报错原因 解决方法 千人全栈 ...

  7. 已解决selenium.common.exceptions.TimeoutException: Message: script timeout

    已解决(selenium模块操作浏览器报错)selenium.common.exceptions.TimeoutException: Message: script timeout 文章目录 报错代码 ...

  8. 解决selenium用cookies时候报错selenium.common.exceptions.InvalidArgumentException: Message: invalid argument

    报错如下: selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: invalid 'xxxxx ...

  9. 报错:selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This versio

    报错: selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This versio ...

  10. selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ executable needs to bein PATH

    使用Selenium模拟浏览器访问淘宝首页,出现报警 from selenium import webdriver import timebrowser = webdriver.Chrome() br ...

最新文章

  1. 表格转化为Latex代码
  2. 【C语言编程练习】5.10寻找水仙数
  3. WEB接口测试之Jmeter接口测试自动化 (四)(持续构建)
  4. SAP Spartacus navigation ui节点的url字段的生成逻辑,同样来自sampledataaddon
  5. 牛客小白月赛12 C 华华给月月出题 (积性函数,线性筛)
  6. 百度贴吧前负责人:做产品16年,我有9条心得[转]
  7. Binding是WPF的核心,WPF的常用数据源绑定有四种
  8. 一文看懂5G射频的“黑科技”
  9. ETL__pentaho__SPOON_PDI
  10. matlab如何将二进制文件写入txt文档中
  11. 计算机英语词汇电子书,计算机英语词汇-打印版.pdf
  12. 如何备考系统集成项目管理工程师?
  13. Intellij IDEA 导入 Maven 项目详细配置以及 IDEA部署和使用过程 (Mac版)
  14. 大于2019电大计算机应用上机表格题,2019年电大计算机应用基础试题及答案重要知识点...
  15. Elasticsearch5.6搭建及拼音中文混合搜索实现
  16. Oracle v$SQLAREA
  17. TRC格列卫(甲磺酸伊马替尼)病毒-宿主融合抑制剂方案
  18. CDH集群中HDFS单点故障解决方案:HA模式(High Availability)
  19. Django 基础(6)-路由Routers-SimpleRouter-DefaultRouter、 action装饰器、URL路径参数
  20. OPPO A59m刷机包|OPPO A59m官方线刷包救砖

热门文章

  1. Bytom Dapp 开发笔记(二):开发流程
  2. 微信企业邮箱添加至Windows邮箱客户端
  3. 匿名游走 Anonymous Walk
  4. Java实现身份证号合法性校验(包含港澳台地区)
  5. WinPE工具箱制作PE系统
  6. 微信开发:微信公众号给粉丝推送通知消息(模板消息)
  7. mac 截图工具只能截取桌面问题
  8. 使用宏定义求圆的周长,面积
  9. unity scripting backend mono vs il2cpp
  10. Win系统 - 你知道 insert 键的隐藏功能吗?