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("=======")

This is my code and it print nothing

Selenium 2.53.1

I've added the Reg and changed IE's security options

What can i do???

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

3 Answers3

0

You haven't mentioned if you are seeing any error. However, using Selenium v3.141.0 I'm able to extract the page_source as per the solutionbelow:

Code Block:

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()

Console Output:

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">工作动态</a></li>
<li><a href="/static/getInfoList?type=news">政策规定</a></li>
<li><a href="/static/getInfoList?type=laws">办事指南</a></li>
</ul>

</body></html>
=======
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • I can get the title, but can't get the source file.I used pyinstaller to package exe and run it on another computer. is this the reason? – user5524535 Jul 20 '20 at 01:04
  • @user5524535 I'm still not sure what exactly you meant by `source file`. As per your code trials you were looking for `page_source`, hence my answer. – undetected Selenium Jul 20 '20 at 07:40
  • I'm sorry, it didn't work for me, but I've asked the other party to re install the system. Take your answer for the work you've done. thank you. – user5524535 Jul 21 '20 at 08:04
0

Have you tried to use the Desired Capabilities?

You could try to launch the IE on Kiosk mode, as stated on the documentation:

-k : Starts Internet Explorer in kiosk mode. The browser opens in a maximized window that does not display the address bar, the navigation buttons, or the status bar.

Following the documentation you could implement on your code by adding the options before you launch the driver:


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("=======")

Daniel
  • 395
  • 4
  • 11
0

I suggest trying to download the latest version of the IEDriverServer from here.

I tried to test your sample code and it works fine.

enter image description here

Deepak-MSFT
  • 10,379
  • 1
  • 12
  • 19
  • I can get the title, but can't get the source file.I used pyinstaller to package exe and run it on another computer. is this the reason? – user5524535 Jul 20 '20 at 01:07