Jackson Walters
Jackson Walters

Reputation: 349

Script to pull an image from a Website

I have a website on which I want to post the current xkcd comic. xkcd provides a link for embedding, but each link has a unique name for each comic. For example, http://imgs.xkcd.com/comics/hotels.png is today's comic.

Is there any way to write a simple script to grab the latest comic from their website? Currently I'm just manually updating the URL on my site which is painful.

Upvotes: 0

Views: 421

Answers (2)

Matt Ball
Matt Ball

Reputation: 359776

Randall provides RSS and Atom feeds for recent XKCDs. Parse one of those to get the latest comics.

Upvotes: 3

Greg Hewgill
Greg Hewgill

Reputation: 992707

Consider the problem for a moment. Where is the name of the current comic image shown? It's shown on the xkcd home page. You could write a script to retrieve the home page, search through the HTML for the current image link, and use that.

Upvotes: 1

Related Questions