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
この URL をブラウザに貼り付けると、「これは無効な URL です」と表示されます。
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;
}