python - Python selenium webdriver什么也没得到,但浏览器通常会显示网页
问题描述
源代码:
from selenium import webdriver
browser = webdriver.Safari()
html_doc = browser.get("http://www.google.com")
#html_doc is empty but the Safari window shows the page normally
#Allow Remote Automation is enabled
这是我第一次使用Selenium,一开始它工作正常,用html_doc正常获取内容,然而,问题发生在几个小时后,重启Python和重启计算机都没有工作。感谢您的任何建议!
解决方案
browser.get
不返回任何东西,这就是为什么html_doc
是空的。如果你想要你需要使用的页面源page_source
browser.get("http://www.google.com")
html_doc = browser.page_source
推荐阅读
- google-apps-script - 在范围谷歌电子表格中计算带有注释的单元格
- tensorflow - Gitlab-CI.yml、requirements.txt 和 Tensorflow
- c# - 如何在 C# 项目中使用 windows 命令行安装 Nuget 包?
- azure-devops - Azure DevOps 开始聊天没有响应单击
- sql - BigQuery:聚合对象数组。获取“不支持引用其他表的相关子查询”
- laravel - 超过 20 秒的最大执行时间
- python-3.x - Tensorflow (.pb) 格式到 Keras (.h5)
- hyperledger-fabric - Hyperledger Fabric CA 在启用 TLS 时向 Node SDK 发布错误的证书(错误的颁发者)
- git - 重命名或移动 Git 存储库中的项目模块并保留历史记录
- java - 使用 JSTL 遍历地图