Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
[Explosm feed] A feed generator for Cyanide & Happiness which includes the images #comics
* Generates a Cyanide & Happiness feed with the images included
* Caches the results to be nice to the server
* Requires memcache and simplehtmldom
* Gist:
// See
$mem = new Memcache;
$feed = "";
$feed_src = $mem->get($feed);
if (empty($feed_src)) {
$feed_src = file_get_contents($feed);
$mem->set($feed, $feed_src, 0, 43200);
$xml = new simplexmlelement($feed_src);
header("Content-type: application/rss+xml");
foreach($xml->channel->item as $item) {
$url = $item->link;
$html = file_get_html($url);
$img_tag = $mem->get($url . '[img]');
if (empty($img_tag)) {
$img_tag = $html->find('#main-comic')[0]->outertext;
$mem->set($url . '[img]', $img_tag);
$item->description = $img_tag;
echo $xml->asxml();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.