首页 > 解决方案 > Selenium 原始页面源

问题描述

我正在尝试在 Selenium 的帮助下获取特定站点的源代码:

Python代码:

driver.page_source 

但它在编码后返回它。

原始文件:

<html>
<head>
    <title>&#x41;&#x41;&#x41;&#x41;&#x41;&#x41;&#x41;&#x41;</title>
</head>
<body>

</body>

在 Chrome 中按“查看页面源代码”时,我看到了正确的原始源代码,没有编码。

如何做到这一点?

标签: pythonseleniumgoogle-chromeselenium-chromedriver

解决方案


您可以尝试使用 Javascript 而不是 Python 内置代码来获取页面源代码。

javascriptPageSource = driver.execute_script("return document.body.outerHTML;")

推荐阅读