运用selenium进行爬虫时,获取的网页中的body内的内容被字符“正在载入中代替”,...
运用selenium进行爬虫时,获取的网页中的body内的内容被字符“正在载入中代替”,请问如何解决。这导致了我无法对网页进行元素提取。print("开始执行")op = webdriver.Chrome(r'C:\Program Files\Google\Chrome\Application\chromedriver.exe')
op.get('http://www.sci-hub.tw.cn/')
e01=op.find_element_by_tag_name('input')
e01=op.find_element_by_tag_name('input')
e01.send_keys('此处为账号')
e02=op.find_elements_by_tag_name('input')
e02.send_keys('此处为密码')
e03=op.find_element_by_tag_name('button')
e03.click()
time.sleep(5)
op.refresh()
html=op.page_source
print(html)
下面务必注意html文件中的“正在载入”下为输出的html源代码:<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>【SciHub学术】免费文献检索论文下载平台</title>
<meta name="keywords" content="SciHub">
<meta name="description" content="SciHub学术文献下载服务平台汇集中国知网、万方数据、维普、读秀等文献数据库,不限地址,随时免费下载,为广大科研人员在学术道路上提供方便快捷的服务!">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta content="always" name="referrer">
<link rel="stylesheet" href="/bootstrap/2.0.4/css/bootstrap.min.css">
<link href="/bootstrap/2.3.2/css/bootstrap-responsive.min.css" rel="stylesheet">
<link href="/ext/font-awesome/3.2.0/css/font-awesome-ie7.css" rel="stylesheet">
<link href="/ext/font-awesome/3.2.0/css/font-awesome.css" rel="stylesheet">
<link rel="stylesheet" href="/skin/bootstrap_lib/css/matrix-style.css?13">
<script src="/skin/Home/Default/js/jquery.min.js?1808"></script>
<script src="/bootstrap/3.2.0/js/bootstrap.min.js?1808"></script>
<script src="/skin/bootstrap_lib/css/matrix.js?18"></script>
</head>
<body style="">
<!--Header-kefu-->
<div class="helper-button" style="position:fixed; width:42px;height:118px;right:6px;top:112px;z-index:10000; _position:absolute;_bottom:auto;_top:expression(eval(document.documentElement.scrollTop+112));"> <a href="http://wpa.qq.com/msgrd?v=3&uin=3366582257&site=qq&menu=yes" target="_blank"></a> </div>
<!--Header-part-->
<div id="header">
<img src="/images/logo/sci.png" alt="学术助手-数字资源">
</div>
<!--close-Header-part-->
<div id="user-nav" class="navbar navbar-inverse">
<ul class="nav">
<li class="dropdown active" id="profile-messages"><a title="" href="#" data-toggle="dropdown" data-target="#profile-messages" class="dropdown-toggle"><i class="icon icon-user"></i><span class="text">Hi,2201231213</span><b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="/r=user/cp"><i class="icon-user"></i> 用户信息</a></li>
<li class="divider"></li>
<li><a href="/r=user/EditInfo"><i class="icon-key"></i> 修改个人信息</a></li>
<!--li class="divider"></li>
<!--li><a href="/r=member/UpdatePassword"><i class="icon-check"></i> 修改密码</a></li-->
<li class="divider"></li>
</ul>
</li>
<li class="active"><a data-original-title="会员时长:11天" class="tip-bottom" href="#"><i class="icon icon-group"></i> <span class="text">有效期(天):11</span></a></li>
<li class=""><a data-original-title="退出登陆" class="tip-bottom" href="/r=user/logout"><i class="icon icon-signout"></i> <span class="text">安全退出</span></a></li>
<li class=""><a data-original-title="公告: 系统开放支持卡密直接登陆!!" class="tip-bottom" href="#"><i class="icon icon-volume-up"></i> <span class="text">公告: 系统开放支持卡密直接登陆!!</span></a></li>
</ul>
</div>
<div id="sidebar"><a href="#" class="visible-phone"><i class="icon icon-home"></i> 资源导航</a>
<ul style="display: block;">
<li class="active"><a href="javascript:load_cont('/lit/vip/',0);"><i class="icon icon-book"></i> <span>中文数据库</span></a> </li>
<li class=""> <a href="/r=user/cp"><i class="icon icon-th-list"></i><span class="text-red">用户信息</span></a></li>
<li class=""> <a href="/tbuy" target="_blank"><i class="icon icon-th-list"></i><span class="text-green">资源订阅</span></a></li>
<!--li> <a href="/r=user/EditInfo"><i class="icon icon-th-list"></i><span class="text-red">修改密码</span></a></li>
<!--li> <a href="http://www.chinacnki.cn/" target="_blank"><i class="icon icon-th-list"></i><span class="text-green">论文查/降重</span></a></li-->
<!--li><a href="/e/tool/gbook/?bid=2"><i class="icon icon-tint"></i> <span>诚招代理</span></a></li-->
<!--li class="content taskStatus" align="center">
<span class="pending"></span>
<span class="text-green">手机扫码快捷访问</span>
<div class="stat" align="center"><img src=""></div>
</li-->
</ul></div>
<!-- 客服系统 -->
<script type="text/javascript" src="/skin/qqkefu/index/js/qqkf/service.js"></script>
<link href="/skin/qqkefu/index/js/qqkf/qqkf.css" type="text/css" rel="stylesheet"><div id="content">
<div id="content-header">
<div id="breadcrumb">
<a data-original-title="返回首页" href="/" class="tip-bottom"><i class="icon-home"></i> 首页</a>
<button type="button" class="btn btn-default navbar-btn btn-success" onclick="load_cont('/lit/vip/',0);">中文库</button>
</div>
</div>
<div class="container-fluid" id="ct">正在载入...</div>
</div>
<script>
function load_cont(val,index)
{
var tVal=val+'?'+parseInt($.now()/30000);
$("#ct").value="正在载入...";
$("#ct").load(tVal);
changeBg(index);
}
function changeBg(index)
{
var alllinks=document.getElementById("sidebar").getElementsByTagName("li");
for(var i=0;i<alllinks.length;i++){
alllinks.className="";//默认未点击时引用的样式
}
alllinks.className="active";//点击切换样式
}
load_cont('/lit/vip/',0);
</script>
</body></html>
页:
[1]