Last active
December 26, 2015 19:18
-
-
Save sestaton/7200050 to your computer and use it in GitHub Desktop.
biostars84811.pl - get pubmed abstract
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use 5.010; | |
use utf8; | |
use strict; | |
use warnings; | |
use Bio::DB::EUtilities; | |
use XML::LibXML; | |
my @ids = (23298400); | |
my $factory = Bio::DB::EUtilities->new(-eutil => 'efetch', | |
-email => '[email protected]', | |
-db => 'pubmed', | |
-retmode => 'xml', | |
-id => \@ids); | |
my $xml = $factory->get_Response->content; | |
my $xml_parser = XML::LibXML->new(); | |
my $dom = $xml_parser->parse_string($xml); | |
my $root = $dom->documentElement(); | |
for my $node ($root->findnodes('//*[text()]')) { | |
my $name = $node->nodeName(); | |
if ($name eq 'Abstract') { | |
for my $child ($node->findnodes('*')) { | |
binmode STDOUT, ":utf8"; | |
say $child->textContent(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment