Skip to content

Instantly share code, notes, and snippets.

@mbutler
Created July 31, 2013 22:01
Show Gist options
  • Save mbutler/6126584 to your computer and use it in GitHub Desktop.
Save mbutler/6126584 to your computer and use it in GitHub Desktop.
OAI-PMH harvester for IRO.
<?php
for ($i=0; $i<=137; $i++) {
$t = $i*100;
$url = "http://ir.uiowa.edu/do/oai/?verb=ListRecords&resumptionToken=3961284/document-export/".$t."//";
$returned_content = get_data($url);
print_r($returned_content);
$target_file = 'iro.xml';
file_put_contents($target_file, $returned_content, FILE_APPEND);
}
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment