我正在从使用java的website下载搜索结果,适用于第一页使用。从Java拨打Java的电话号码
URL url = new URL(
"http://www.geocaching.com/seek/nearest.aspx?country_id=79&as=1&ex=0");
BufferedReader in = new BufferedReader(new InputStreamReader(
url.openStream()));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
in.close();
但是我怎么能得到结果的第二页?到第二页的链接使用javascript调用javascript:__doPostBack('ctl00$ContentBody$pgrBottom$lbGoToPage_2','')
,调用该函数:
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['aspnetForm'];
if (!theForm) {
theForm = document.aspnetForm;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
我想,我需要从我的Java PROGRAMM调用该函数来获取第二页,但如何?
我正在尝试下载所有数据以供日后处理。我认为Selenium不会帮助。 – multiholle
@multiholle您可以使用Selenium浏览您感兴趣的页面,并将每个页面的相关内容保存到一个文件中,然后在另一个时间处理该文件。 –
@multiholle你应该手动完成这篇文章。看看我提到的链接。 – toc777