I have been trying to harvest metadata using OAI-PMH protocol and also using a perl based harvester called 'Harvey' but I seem to be stuck at the below issue. My last resumptionToken is "resumptionToken=2019-01-22T00:51:30Z!2037-01-01T00:00:00Z!!oai_dc!6045389!7351939!oai:union.ndltd.org:IBICT/aoi:localhost:jspui/2251" please let me know where I should add this on the Perl code for the process to continue? On the Perl code below, I see the variable resumptionToken at 4 places (Lines: 12, 21, 52,57).

$| = 1; my $baseURL = 'http://union.ndltd.org/OAI-PMH/'; my $filename = 'aaaaafna'; my $resumptionToken = '2019-01-22T00:51:30Z!2037-01-01T00:00:00Z!!oai_ +dc!6045389!7351939!oai:union.ndltd.org:IBICT/aoi:localhost:jspui/2251 +'; use LWP::UserAgent; $ua = LWP::UserAgent->new; # before running this script, execute: # export http_proxy=http://localhost:<port>/ where <port> is your +cntlm port $ua->env_proxy(); do { my $reqURL = $baseURL.'?verb=ListRecords&'.(($ eq '')?'metadataPref +ix=oai_dc':'resumptionToken='.$resumptionToken); # my $reqURL = $baseURL.'?verb=Identify'; my $req = HTTP::Request->new( GET => $reqURL ); print "Harvesting $reqURL\n"; my $state = 0; my $res; while ($state == 0) { $res = $ua->request($req); if ($res->code == 503) { my $sleep = $res->header ('Retry-After'); if (not defined ($sleep) || ($sleep < 0) || ($sleep > 86400)) { $state = 1;} else { print "Sleeping for $sleep seconds\n"; sleep ($sleep); } } else { $state = 1; } } my $content = $res->content; my $records = (split (/<metadata>/, $content))-1; print "Saving response with $records records to $filename.xml\n"; open (FILE, ">$filename.xml"); print FILE $content; close (FILE); $filename++; $resumptionToken = ''; if ($content =~ /<resumptionToken[^>]*>([^<]+)<\/resumptionToken>/) { $resumptionToken = $1; } } while ($resumptionToken ne '');

In reply to Meta Data Harvesting Using perl by jarviscrypter

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.