Sunday, August 31, 2008

View source code for iPhone RSS feed

I tried to view the Slashdot RSS feed on my iPod Touch, but instead of an RSS feed I was redirected to a specially formatted feed for iPhones. Very nice!

The iPhone specific URL is http://reader.mac.com/mobile/v1/http://rss.slashdot.org/Slashdot/slashdot .

I was curious to about the source code of the page, really just to see if there was any interesting markup. So I tried to view the URL in Firefox... no dice. I was shown a page saying, "This Application Is Viewable Only On iPhone".

Hmm... it was time to cheat a little then. I googled around for the User Agent that the iPhone sends, opened a terminal and entered...




# curl -A "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3 " "http://reader.mac.com/mobile/v1/http://rss.slashdot.org/Slashdot/slashdot"

I can now take a look at what makes an iPhone/iPod specific feed :)

11 comments:

Anonymous said...

Cool, nice tip.

Getting my iTouch soon. Not sure whether to jail-break it to install 3rd party apps. Most likely not as that will void the warranty.

Scott Barr said...

Thanks kennii. curl probably has to rate as one of my favorite command line tools.

I think you have a few favorites of your own?

Scott Barr said...

Oh yeah... I wouldn't jail-break my iTouch either. I don't think the extra apps is worth being a victim of the arms race between Apple and the guys trying to open it up.

Maybe just get a iPhone?

Anonymous said...

Purchased the iphone software upgrade(2.1) for itouch yesterday. Loving the download of a dozen free apps from the app store.

Thought abt iphone actually. Have to wait till the end of 2008, whereby starhub will start offering phone contracts with iphone.
http://www.straitstimes.com/Latest%2BNews/Singapore/STIStory_236556.html

Until then, itouch will be cool enuff for me.

Scott Barr said...

@defunkt tweeted this option that makes use of a bookmarklet.

http://bit.ly/dvbp1X

Scott Barr said...

@defunkt tweeted this option that makes use of a bookmarklet.

http://fettig.net/weblog/2007/07/02/view-source-for-safari-on-iphone/

Anonymous said...

I have a question. If I was to attempt to do this too, how do I get this "terminal" to enter the user agent?

Thanks

Scott Barr said...

Hey Mr Anonymous

- OSX : Terminal.app
- Linux : Use any number of terminal apps
- Windows : Use the command line.

No matter what OS or terminal you're using, Curl will need to be installed and on your PATH.

You could also use wget of lynx instead of curl, but the command and options will obviously be different for each.

Anonymous said...

Thanks Scott,

I actually found that you can also use the "Tamper Data" plugin for Firefox. It allows you to edit the User Agent data before the page loads. Thanks for the script!

Anonymous said...

What will be the exact user agent for iPad iOS 5

Scott Barr said...

@Anonymous My iPad (running iOS5) shows up as...

Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B176 Safari/7534.48.3

Take a look at What's My User Agent? to find out the exact user agent string of any browser you hit their site with.