POST请求.aspx页 [英] POST request .aspx page
问题描述
iam试图从.aspx页检索一些数据.我想做的是告诉服务器我要从页面的下拉菜单中获得某个值.如果iam没错,您可以通过更改以下值来做到这一点:"ctl00 $ holder $ ddlEntry".如果您是普通用户,则要单击刷新按钮.由于在jsoup中未实现javascript,因此我试图通过发出与刷新按钮相同的发布请求来获取数据.我在做什么错了?
iam trying to retrieve some data from an .aspx page. What i want to do is to tell the server that i want to have a certain value from the dropdown menu from the page. If iam not wrong you can do this by changing this value : "ctl00$holder$ddlEntry". When you are a regular user you want to hit the refresh button. Since javascript is not implemented in jsoup, i was trying to get the data by making the same post request as the refresh button. what am i doing wrong?
我的问题是:我的页面没有更新,而我仍然在访问同一页面.
edit: what my problem is : my page is not updating , iam still getting the same page.
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
String url = "http://extranet.net4gas.cz/capacity_ee_point.aspx";
Document doc = Jsoup.connect(url).get();
Elements viewState = doc.select("input[name=__VIEWSTATE");
Elements eventValidation = doc.select("input[name=__EVENTVALIDATION]");
Map<String,String> allFields = new HashMap<String,String>();
allFields.put("ctl00$holder$ScriptManager1", "ctl00$holder$UpPanel");
allFields.put("ctl00$holder$break", "rbTypC1");
allFields.put("ctl00$holder$enex", "rbTypB1");
allFields.put("ctl00$holder$ddlEntry", "4"); //resembles value in dropdown menu
allFields.put("ctl00$holder$ddlMonth1", "11");
allFields.put("ctl00$holder$ddlYear1", "2013");
allFields.put("ctl00$holder$ddlMonth2", "12");
allFields.put("ctl00$holder$ddlYear2", "2018");
allFields.put("__EVENTTARGET", "");
allFields.put("__EVENTARGUMENT", "");
allFields.put("__LASTFOCUS", "");
allFields.put("__VIEWSTATE", viewState.val());
allFields.put("__EVENTVALIDATION", eventValidation.val());
allFields.put("__ASYNCPOST", "true");
allFields.put("ctl00$holder$bRefresh", " Refresh ");
System.out.println(allFields);
Connection.Response res = Jsoup.connect(url)
.data(allFields)
.userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0")
.timeout(5*1000)
.method(Method.POST).
execute();
Document doc2 = Jsoup.connect(url)
.cookies(res.cookies())
.timeout(5*1000)
.get();
System.out.println(doc2.html());
}
推荐答案
在这种情况下,您可以使用Selenium Libary for Java.它模拟一个特定的浏览器,并且可以单击按钮"等等.
in this case you can use the Selenium Libary for Java. It emulates a specific Browser and can hit Buttons and so on.
这篇关于POST请求.aspx页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!