2
driver = webdriver.Ie()
driver.implicitly_wait(5)
url = "http://nontax.hebcz.cn"
driver.get(url)
driver.maximize_window()
print("=======")
print(driver.page_source)
print("=======")

这是我的代码,它什么也不打印

硒 2.53.1

我添加了 Reg 并更改了 IE 的安全选项

我能做些什么???

4

3 回答 3

0

您是否尝试过使用所需的功能

您可以尝试在 Kiosk 模式下启动 IE,如文档中所述:

-k :以 kiosk 模式启动 Internet Explorer。浏览器在不显示地址栏、导航按钮或状态栏的最大化窗口中打开。

按照文档,您可以通过在启动驱动程序之前添加选项来实现代码:


from selenium import webdriver

options = webdriver.IeOptions() options.add_argument('-k') 
options.force_create_process_api = True 
driver = webdriver.Ie(options=options)

driver.implicitly_wait(5)
url = "http://nontax.hebcz.cn"
driver.get(url)
print("=======")
print(driver.page_source)
print("=======")

于 2020-07-16T09:49:42.123 回答
0

你没有提到你是否看到任何错误。但是,使用Selenium v3.141.0,我可以page_source按照以下解决方案提取:

代码块:

from selenium import webdriver

driver = webdriver.Ie(executable_path=r'C:\WebDrivers\IEDriverServer.exe')
driver.get('http://nontax.hebcz.cn/')
print("Page title is: %s" %(driver.title))
print("=======")
print(driver.page_source)
print("=======")
driver.quit()

控制台输出:

Page title is: 河北省非税云缴费平台-
=======
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">

<meta name="viewport" content="width=1200">
<meta name="_csrf" content="711baa60-38b0-4328-8704-f404f3d08c49">
<title>河北省非税云缴费平台-</title>
<script src="/static/js/jquery-1.9.1.min.js"></script>
<link href="/static/images/favicon.ico" rel="shortcut icon" type="image/x-icon">
<link href="/static/css/style.css" rel="stylesheet" type="text/css">
<script src="/static/js/zzsc.js" type="text/javascript"></script>
<script type="text/javascript">var footer_Positon =0;$(function () {var token =$("meta[name='_csrf']").attr("content");$(document).ajaxSend(function(e,xhr,options) {xhr.setRequestHeader("CSRFToken",token);});});$(document).ready(function(){var usernav =document.getElementById('usernav');var u =document.getElementById('u');u.onmouseover=function(){usernav.style.display='block'
}
u.onmouseout=function(){usernav.style.display='none'
}
})
</script>
<script type="text/javascript">function unUsed() {alert("缴费大厅暂未开放,请耐心等候!");}
function unInvoice() {alert("国庆间暂停访问!");}
</script>
<style>.footer{height:99px;width:100%;position:fixed;bottom:0;}</style>
</head>
<body>
<div style="min-width: 1200px;">
<div class="top_head">
<div class="topnav">
<ul>
<li><a href="/static/getIndex">首页 </a></li>
<li id="u">
<a href="#">用户中心 <span class="pot"></span></a>
<div class="user_list" id="usernav">
<span class="list_cur"><a href="/web/main/view?path=web/user/userInfo">个人信息</a></span>
<span><a href="/web/main/view?path=web/paycenter/payorderlist">缴费列表</a></span>
<span><a href="/web/main/view?path=web/paycenter/pay">常用缴费</a></span>
<span><a href="/web/main/view?path=web/paycenter/electronic-bill">电子票据</a></span>
</div>
</li>
<li><a href="/unit/main/view?path=unit/index">电子票据</a></li>
<li><a href="/bill/billCheck">票据查验</a></li>
<li><a href="/static/getInfoList?type=notice">工作动态&lt;/a></li>
<li><a href="/static/getInfoList?type=news">政策规定</a></li>
<li><a href="/static/getInfoList?type=laws">办事指南</a></li>
</ul>

</body></html>
=======
于 2020-07-16T09:33:47.640 回答
0

我建议尝试从这里下载最新版本的 IEDriverServer 。

我试图测试你的示例代码,它工作正常。

在此处输入图像描述

于 2020-07-17T06:05:55.497 回答