当前位置:编程学习 > JAVA >>

抓取有cookie值拦截的网站数据

--------------------编程问答-------------------- 注册都没有啊。。我擦,我登陆不了 --------------------编程问答--------------------
引用 1 楼 huxiweng 的回复:
注册都没有啊。。我擦,我登陆不了
  什么意思?注册?这个是公共查询部分,不需要注册,登陆的 --------------------编程问答-------------------- 你给的地址拦截了。直接到   http://www.yesinfo.com.cn/publicInfoService/index.action --------------------编程问答-------------------- 输入你的url,跳了:http://www.yesinfo.com.cn/publicInfoService/index.action
引用 2 楼 gybciy1s1s1 的回复:
Quote: 引用 1 楼 huxiweng 的回复:

注册都没有啊。。我擦,我登陆不了
  什么意思?注册?这个是公共查询部分,不需要注册,登陆的
--------------------编程问答--------------------
引用 4 楼 huxiweng 的回复:
输入你的url,跳了:http://www.yesinfo.com.cn/publicInfoService/index.action
Quote: 引用 2 楼 gybciy1s1s1 的回复:

Quote: 引用 1 楼 huxiweng 的回复:

注册都没有啊。。我擦,我登陆不了
  什么意思?注册?这个是公共查询部分,不需要注册,登陆的


引用 4 楼 huxiweng 的回复:
输入你的url,跳了:http://www.yesinfo.com.cn/publicInfoService/index.action
Quote: 引用 2 楼 gybciy1s1s1 的回复:

Quote: 引用 1 楼 huxiweng 的回复:

注册都没有啊。。我擦,我登陆不了
  什么意思?注册?这个是公共查询部分,不需要注册,登陆的
对啊,cookie里面做判断了,WLSESSIONID这个没有值,所以就跳到其他页面去了,这就是这个帖子想解决的问题,我想到了用httpclient带cookie去访问,但是没办法动态拿到正确的WLSESSIONID值 --------------------编程问答-------------------- http://www.yesinfo.com.cn/pqs_revision/pages/jsp/popuPublic.jsp  查询的页面 --------------------编程问答-------------------- Java的htmlunit应该可以全面模拟浏览器。
你也可以想办法集成phantomjs,我用phantomjs试了一下:
phantom.outputEncoding="gb2312";
var page = require('webpage').create();
page.viewportSize = { width: 1024, height: 768 };
page.settings.userAgent = 'Mozilla/5.0 (Windows NT 5.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36'; //chrome
page.settings.loadImages = true;
page.settings.javascriptEnabled = true;
page.open("http://www.yesinfo.com.cn/pqs_revision/pages/jsp/popuPublic.jsp", function(status) {
page.onUrlChanged = function(url) { //当地址变化
console.log("page url :"+url);
};
if (status !== 'success') {
        console.log('FAIL to load the address');
phantom.exit();
    } else {
window.setTimeout(function () {
page.evaluate(function () {
document.querySelector('input[name=cont_id]').value = 'ESPU8040903';
document.querySelector('input[name=Submit12]').click();
});
}, 2000);
window.setTimeout(function () {
var cookie=page.evaluate(function () {
return document.cookie;
});
var result=page.evaluate(function () {
return document.querySelector('.sub_title ~ table').innerHTML;
});
console.log("cookie : "+cookie);
console.log("result : "+result);
phantom.exit();
}, 5000);
    }    
});

结果:
补充:Java ,  Java EE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,