您的位置:首页 > 其它

爬虫遇到取到网页为reload的问题

2014-07-09 09:49 106 查看
有的网站防采集,会在页面加上this.window.location.reload(),这时候你就会得到如下代码:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<iframe height="0" width="0" style="border: 0px;" src="http://www.***.cn/***/***_cookie.html"></iframe>
<script type="text/javascript">
setTimeout(function(){
this.window.location.reload();
}, 1000);
</script></body>
</html>

这样你就取不到他的网页内容了,但是浏览器可以正常显示

这时候你需要在爬虫的时候添加cookie,比较直接的就是静态的添加上浏览器访问时的cookie,也可以根据他的地址动态取(我没有试过动态取)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: