我正在尝试在此网址上加载团队编号列表:http://www.firstinspires.org/team-event-search/event?id=17351。如您所见,页面渲染正常,团队列表加载正常。
但是,当我发出HTTP请求时,我似乎收到了原始JSP代码而不是响应中的团队列表。
有没有办法让HttpURLConnect在JSP代码完全运行后获取页面,或者我在咆哮错误的树(即需要使用其他方法)?
我的获取HTTP内容的块:
public static String getURL(String urlString){
Logger.info(String.format("Fetching URL: %s", urlString));
try {
URL url = new URL(urlString);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestProperty("X-TBA-App-Id", APPID);
conn.setRequestProperty("User-Agent", "Mozilla/42.0");
conn.setRequestProperty("Referer", "usfirst.org, firstinspires.org");
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line = in.readLine();
StringBuilder response = new StringBuilder();
while (line != null){
response.append(line);
line = in.readLine();
}
conn.disconnect();
return response.toString();
} catch (Exception e){
Logger.error("Failure", e);
return null;
}
}
响应(使用JSP代码剪切到部件):
<div class="hidden-sm hidden-xs col-md-2" data-field="country">Country</div> </div>
<% for(var i=0;i<item._source.number_teams;i++) { %>
<div class="row">