开发者

Script to pull an image from a Website

开发者 https://www.devze.com 2023-04-09 19:39 出处:网络
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, h开发者_运维问答ttp://imgs.xkcd.com/co

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, h开发者_运维问答ttp://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.


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


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.

0

精彩评论

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