-
-
Save zoffixznet/0f54957ea784dc52e43cee0e0766c0ff to your computer and use it in GitHub Desktop.
This file contains 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
use WWW; | |
use DOM::Tiny; | |
constant URL = 'https://www.ncbi.nlm.nih.gov/pubmed'; | |
constant OUT_FILE = 'results.txt'.IO; | |
sub make-term (:$term, :$year) { | |
'(' ~ $term ~ ' AND (("' ~ $year ~ '/01/01"[PDat] : "' ~ $year ~ '/12/31"[PDat])))' | |
} | |
my @terms = "terms.txt".IO.lines; | |
for @terms -> $term { | |
say "Doing searches for $term"; | |
for 1990..2000 -> $year { | |
print "\t...year $year "; | |
my $results-num = DOM::Tiny.parse(post URL, term => make-term :$term, :$year) | |
.at('meta[name="ncbi_resultcount"]').attr: 'content'; | |
say "Found $results-num results"; | |
OUT_FILE.spurt: :append, "$year,$term,$results-num\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment