开发者

Fetching iTunes RSS feed with Java

I am willing to fetch iTunes public RSS feed from a appengine java app.

In dev server, here is what I try:

URL url = new URL("http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topsongs/limit=10/xml");
BufferedReader reader = new BufferedRead开发者_如何学运维er(new InputStreamReader(url.openStream()));

And that is the response:

<?xml version="1.0" encoding="utf-8"?> <feed xmlns:im="http://itunes.apple.com/rss" xmlns="http://www.w3.org/2005/Atom" xml:lang="en"> <id>http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topsongs/limit=10/xml</id> <title>iTunes Store: Top Songs</title> <updated>2010-11-09T12:45:58-07:00</updated> <link rel="alternate" type="text/html" href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewTop?id=38&amp;popId=1"/> <link rel="self" href="http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topsongs/limit=10/xml"/> <icon>http://phobos.apple.com/favicon.ico</icon> <author><name>iTunes Store</name><uri>http://www.apple.com/itunes/</uri></author> <rights>Copyright 2008 Apple Inc.</rights>

There is a link, "http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topsongs/limit=10/xml", which is displayed. It is the same URL that the one I give to the java URL object...

If I open this link in the browser, I get the correct XML response.

I tried to set a different user-agent, but nothing changes.

Thanks for any help.


If you try "View source" in your browser, you will see the same as you see with your Java snippet.


It was my mistake.

Before outputting the XML response, I were writting some "debug" html data. Thus, the XML was seen like HTML code, but since the XML contained HTML redirections attributes, I was redirected!

Thanks for your time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜