1
我与WebHarvest合作,从需要在登录一个网站抓取数据WebHarvest找不到响应头
它的设置是这样的:
1 =登录页面
页2 =登录验证页面
第3页=统计页面
在第2页设置cookie。当监控第2页与萤火虫开我得到这些标题:
Connection Keep-Alive
Content-Type text/html; charset=UTF-8
Date Tue, 23 Oct 2012 18:25:12 GMT
Keep-Alive timeout=15, max=100
Server Apache/2.0.64 (Win32) JRun/4.0 SVN/1.3.2 DAV/2
Set-Cookie SESSION=hej123;expires=Thu, 16-Oct-2042 18:25:12 GMT;path=/
Transfer-Encoding chunked
调用同一个页面WebHarvest我只得到这些头时:
Date=Tue, 23 Oct 2012 18:31:51 GMT
Server=Apache/2.0.64 (Win32) JRun/4.0 SVN/1.3.2 DAV/2
Transfer-Encoding=chunked
Content-Type=text/html; charset=UTF-8
看来,三个头(设置Cookie ,Connection和Keep-Alive)都没有被WebHarvest找到。第1页,第2页和第3页是dummys,所以没有进行实际验证。该Cookie总是在服务器端设置页面2.
这里是WebHarvest代码我目前正在使用:
<var-def name="content2">
<html-to-xml>
<http method="post" url="http://myurl.com/page2.cfm">
<http-param name="Login">sigge</http-param>
<http-param name="Password">hej123</http-param>
<http-param name="doLogin">Logga in</http-param>
<loop item="currField">
<list>
<var name="ctxtNewInputs" />
</list>
<body>
<script><![CDATA[
item = (NvPair) currField.getWrappedObject();
SetContextVar("itemName", item.name);
SetContextVar("itemValue", item.value);
]]></script>
<http-param name="${item.name}"><var name="itemValue" /></http-param>
</body>
</loop>
<script><![CDATA[
String keys="";
for(int i=0;i<http.headers.length;i++) {
keys+=(http.headers[i].key + "=" + http.headers[i].value +"\n---\n");
}
SetContextVar("myCookie", keys);
]]></script>
<file action="write" path="c:/kaka.txt">
<var name="myCookie"/>
</file>
</http>
</html-to-xml>
</var-def>
编辑:检查时,我注意到该cookie在WebHarvest设置,即使 无法以编程方式找到http标头。是否有可能使用某些响应标头?
有没有人知道解决这个问题?
谢谢你,最好的问候, SiggeLund