<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>discontents &#187; birthdays</title>
	<atom:link href="http://discontents.com.au/tag/birthdays/feed" rel="self" type="application/rss+xml" />
	<link>http://discontents.com.au</link>
	<description>working for the triumph of content over form, ideas over control, people over systems</description>
	<lastBuildDate>Wed, 16 May 2012 14:11:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>ADB DIY RSS</title>
		<link>http://discontents.com.au/shed/hacks/adb-diy-rss</link>
		<comments>http://discontents.com.au/shed/hacks/adb-diy-rss#comments</comments>
		<pubDate>Wed, 04 Feb 2009 06:34:24 +0000</pubDate>
		<dc:creator>tim</dc:creator>
				<category><![CDATA[hacks]]></category>
		<category><![CDATA[ADB Online]]></category>
		<category><![CDATA[birthdays]]></category>
		<category><![CDATA[rss]]></category>

		<guid isPermaLink="false">http://discontents.com.au/?p=653</guid>
		<description><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=ADB+DIY+RSS&amp;rft.aulast=Sherratt&amp;rft.aufirst=Tim&amp;rft.subject=hacks&amp;rft.source=discontents&amp;rft.date=2009-02-04&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://discontents.com.au/shed/hacks/adb-diy-rss&amp;rft.language=English"></span>
So I was thinking, wouldn&#8217;t it be nice if the Australian Dictionary of Biography&#8216;s &#8216;born on this day&#8216; feature could be made available as an RSS feed. Every morning you&#8217;d get a new list of biographies delivered direct to your feed reader. And so&#8230; [sounds of xpath wrangling and PHP coding] here it is. It&#8217;s [...]]]></description>
			<content:encoded><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=ADB+DIY+RSS&amp;rft.aulast=Sherratt&amp;rft.aufirst=Tim&amp;rft.subject=hacks&amp;rft.source=discontents&amp;rft.date=2009-02-04&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://discontents.com.au/shed/hacks/adb-diy-rss&amp;rft.language=English"></span>
<abbr class="unapi-id" title="http://discontents.com.au/?p=653"><!-- &nbsp; --></abbr>
<p>So I was thinking, wouldn&#8217;t it be nice if the <em>Australian Dictionary of Biography</em>&#8216;s &#8216;<a href="http://www.adb.online.anu.edu.au/scripts/adbp-births-deaths.php">born on this day</a>&#8216; feature could be made available as an RSS feed. Every morning you&#8217;d get a new list of biographies delivered direct to your feed reader. And so&#8230;</p>
<p>[sounds of xpath wrangling and PHP coding]</p>
<p><a href="http://discontents.com.au/shed/adb/born-rss.php">here it is</a>.</p>
<p>It&#8217;s pretty simple – it harvests all the links of people born on the current day, then loops through the links to gather the first paragraph of each biography. Then it&#8217;s just a matter of writing everything to an RSS file.<span id="more-653"></span></p>
<p>In case you missed it, I also created a <a href="http://discontents.com.au/shed/adb/portraits/adb-portraits-1.rss">Media RSS feed</a> for portrait images used in the ADB. This enables them to be <a href="http://discontents.com.au/shed/adb/portraits/adb-portrait-browser.html">viewed in CoolIris</a>.</p>
<p>Code follows&#8230;</p>
<pre>
<pre class="brush: php">
&lt;?php
function getPage($url, $ch) {
	curl_setopt($ch, CURLOPT_URL,$url);
	$html= curl_exec($ch);
	if (!$html) {
		echo &quot;cURL error number:&quot; .curl_errno($ch);
		echo &quot;cURL error:&quot; . curl_error($ch);
		exit;
	}
	return $html;
}
$url = &quot;http://www.adb.online.anu.edu.au/scripts/adbp-births-deaths.php&quot;;
$userAgent = &#039;Googlebot/2.1 (http://www.googlebot.com/bot.html)&#039;;

$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$html = getPage($url, $ch);

$dom = new DOMDocument();
@$dom-&gt;loadHTML($html);

$xpath = new DOMXPath($dom);
$hrefs = $xpath-&gt;evaluate(&quot;//ul[@class=&#039;pb-results&#039;][1]/li/a&quot;);
$titles = $xpath-&gt;evaluate(&quot;//ul[@class=&#039;pb-results&#039;][1]/li/a/text()&quot;);

echo &quot;&lt;?xml version=&#039;1.0&#039;?&gt;\n&quot;;
echo &quot;&lt;rss version=&#039;2.0&#039;&gt;\n&quot;;
echo &quot;&lt;channel&gt;\n&quot;;
echo &quot;&lt;title&gt;ADB Online - Born on this day&lt;/title&gt;\n&quot;;
echo &quot;&lt;link&gt;http://www.adb.online.anu.edu.au/scripts/adbp-births-deaths.php&lt;/link&gt;\n&quot;;
echo &quot;&lt;description&gt;A list of all those people in the Australian Dictionary of Biography who were born on this day.&lt;/description&gt;\n&quot;;
for ($i = 0; $i &lt; $hrefs-&gt;length; $i++) {
	$href = $hrefs-&gt;item($i);
	$title = $href-&gt;nodeValue;
	$bio = &quot;&quot;;
	$url = &quot;http://www.adb.online.anu.edu.au&quot; . substr($href-&gt;getAttribute(&#039;href&#039;),2);
	$html = getPage($url, $ch);
	$dom = new DOMDocument();
	@$dom-&gt;loadHTML($html);
	$xpath = new DOMXPath($dom);
	$paras = $xpath-&gt;evaluate(&quot;//div[@id=&#039;content&#039;]/p[1]/text()&quot;);
	foreach ($paras as $para) {
		$bio .= $para-&gt;nodeValue;
	}
	$bio .= &quot;...&quot;;
	$bio = htmlspecialchars($bio, ENT_QUOTES);
	$bio = str_replace(&#039;\n&#039;, &#039;&#039;, $bio);
	echo &quot;&lt;item&gt;\n&quot;;
	echo &quot;&lt;title&gt;$title&lt;/title&gt;\n&quot;;
	echo &quot;&lt;link&gt;$url&lt;/link&gt;\n&quot;;
	echo &quot;&lt;description&gt;$bio&lt;/description&gt;\n&quot;;
	echo &quot;&lt;/item&gt;\n&quot;;
}
echo &quot;&lt;/channel&gt;\n&quot;;
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://discontents.com.au/shed/hacks/adb-diy-rss/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

