我正在研究 Rss 提要。我正在使用 DOM 解析器
The actual link is:
http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNEd3ZGNLp5P-6bn44JmKbPfQimTyQ&url=http://www.foxnews.com/world/2012/09/21/libyans-storm-ansar-al-sharia-compound-in-backlash-attack-on-us-consulate/
After executing the function xml = parser.getXmlFromUrl(URL);
URL=https://news.google.com/news/feeds?ned=us&topic=w&output=rss
In xml Iam getting the link as:
http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNHrclA7rxiQuEvAA_o9ZDRlZQFLkg&url=http://www.usatoday.com/news/world/story/2012/09/21/libyans-storm-militia-in-backlash-of-attack-on-us/57821580/1
当我将此网址粘贴到浏览器中时,它显示“这是一个无效的网址”。
How to get the a valid url? Could anyone please help me.
下面的函数是从 url 获取 xml:
public String getXmlFromUrl(String url) {
String xml = null;
try {
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
xml = EntityUtils.toString(httpEntity);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// return XML
return xml;
}