python - Selenium 原始页面源
问题描述
我正在尝试在 Selenium 的帮助下获取特定站点的源代码:
Python代码:
driver.page_source
但它在编码后返回它。
原始文件:
<html>
<head>
<title>AAAAAAAA</title>
</head>
<body>
</body>
在 Chrome 中按“查看页面源代码”时,我看到了正确的原始源代码,没有编码。
如何做到这一点?
解决方案
您可以尝试使用 Javascript 而不是 Python 内置代码来获取页面源代码。
javascriptPageSource = driver.execute_script("return document.body.outerHTML;")
推荐阅读
- android - 如何接收最近屏幕解锁的日志?
- graphql - Contentful GraphQL API 中的全文搜索
- c# - 使用 Angular.js 路由将 UI 视图与 ASP.net Razor 分离的问题
- javascript - React Hooks 和 Redux - 从动作创建者那里获得价值的麻烦
- jenkins - 如何在 sh 命令中引用 groovy 变量
- javascript - 我不明白这个变量声明在我的队列算法练习中是如何变化的?
- python-3.x - Excel 列到 Spacy Docu(令牌,引理)
- java - 正则表达式排除除目录和字符串匹配文件之外的所有内容
- php - 根据日期对文本字母顺序进行排序
- reactjs - React-card-flip 一键翻转所有卡片