Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use XML::LibXML;
- use XML::LibXML::Reader;
- use HTML::TableExtract;
- use LWP::UserAgent;
- use Data::Dumper;
- my %relator;
- my $code = 0;
- my $fullname = 0;
- my $code_v;
- my $ua = LWP::UserAgent->new;
- my $url = "https://www.loc.gov/marc/relators/relacode.html";
- $ua->agent('Mozilla/5.0'); # the default 'lib-www/<version>' UA is not accepted
- my $response = $ua->get( $url ) or die "Could not retrieve URL $url\n";
- my $content = $response->decoded_content;
- if ($response) {
- print "Response successful.\n";
- }
- if ($content) {
- print "Hey! We have some content!\n";
- }
- #print Dumper($content);
- # extract table data
- my $te = HTML::TableExtract->new( headers => [('code', 'relator term')] );
- $te->parse($content);
- my $table = $te->first_table_found;
- my @columns = $table->columns();
- print Dumper(@columns) ."\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement