我正在使用jsoup来解析html,但我想解析链接,以便将来网站的网址或网址的一部分被更改,其在应用中也会自动更改, 假设我有以下链接:
这个链接是针对季节= 20132014 的特定季节,在链接中提到这个链接是针对2013-2014这个季节每年的变化,我如何解析这个链接在jsoup所以如果这个季节代码被更改,我的应用程序也改变了它, 这就是我在这里用代码做的事情:
String BLOG_URL="http://www.nhl.com/ice/playerstats.htm?season=20132014&gameType=2&team=ANA&position=S&country=&status=&viewName=summary";
Document document = Jsoup.connect(BLOG_URL).get();
Element nodeBlogStats = document.getElementById("forwards");
for (org.jsoup.nodes.Element row : nodeBlogStats.select("tr")) {
for (org.jsoup.nodes.Element column : row.select("td")) {
for (int i = 0; i <= 5; i++) {
for (org.jsoup.nodes.Element n : column.select("td#LW" + i)) {
result += column.text();
}
}
}
result = "<u>" + result + "</u>";
result += "<br><br>";
}
如果更改了orignal,我想动态/自动更新此BLOG_URL, 提前致谢
答案 0 :(得分:0)
你可以创建&#34; next&#34;季节链接并使用jsoup来获得结果。你看到链接
的那一刻String BLOG_URL="http://www.nhl.com/ice/playerstats.htm?season=20142015&gameType=2&team=ANA&position=S&country=&status=&viewName=summary";
会导致网站声明该网页无法使用。您可以抓取此信息并忽略该链接。但是,如果它可用,您的应用程序可以切换到新链接并测试下一个链接&#34; 20152016&#34;直到可以使用。