我正在尝试自动化一些东西,但最近一个网站设置了一个协议障碍,需要达成一致才能访问其他页面和文件。
https://www.paoilandgasreporting.state.pa.us/publicreports/Modules/DataExports/DataExports.aspx
我无法使用下面的 java 后查询代码绕过它,我得到的只是该协议障碍页面的 html 内容:
HttpClient httpClient = new HttpClient();
httpClient.getParams().setParameter(
ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true);
PostMethod postMethod = new PostMethod(
"https://www.paoilandgasreporting.state.pa.us/publicreports/Modules/Welcome/Welcome.aspx") {
@Override
public boolean getFollowRedirects() {
return true;
}
};
postMethod.addParameter("ctl00$MainContent$AgreeButton", "Agree");
try {
httpClient.executeMethod(postMethod);
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if (postMethod.getStatusCode() == HttpStatus.SC_OK) {
String resp = postMethod.getResponseBodyAsString();
System.out.println(resp);
} else {
// ...postMethod.getStatusLine();
}
我使用 firebug 获得了 post 参数,即使我尝试添加其他两个 post 参数,即使这也无济于事
//postMethod.addParameter("__EVENTVALIDATION","%2FwEWAwLA5%2FC9CwLuhr%2FJBgKws9WDC7O5VJxkt6T7bUFREi%2BvwFPh%2FDo37JKON9tdbF4jnCXF");
// postMethod.addParameter ("__VIEWSTATE","%2FwEPDwUKMTAxODQ0NzY0Nw9kFgJmD2QWAgIDD2QWBAIBDxYCHgRUZXh0BdgQPGRpdiBzdHlsZT0iaGVpZ2h0OiAxNDlweDsgd2lkdGg6IDk1MnB4OyBiYWNrZ3JvdW5kLXJlcGVhdDogbm8tcmVwZWF0OyBiYWNrZ3JvdW5kLWltYWdlOnVybChodHRwczovL3d3dy5haHMyLmRlcC5zdGF0ZS5wYS51cy9pbWFnZXMvZGVwX2V4dGVybmFsX21haW5fYmFubmVyXzIuanBnKSI%2BCgoJPGEgc3R5bGU9ImhlaWdodDoxMDBweDsgd2lkdGg6MzkwcHg7IGxlZnQ6MHB4OyB0b3A6MHB4OyBwb3NpdGlvbjpyZWxhdGl2ZTsgZ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