Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use WWW;
- use DOM::Tiny;
- use URI::Encode;
- constant URL = 'https://www.ncbi.nlm.nih.gov/pubmed';
- my $fh = open :w, 'results5.txt';
- constant OUT_FILE = 'results5.txt'.IO;
- sub make-term (:$term, :$year) {
- '(' ~ $term ~ '[Title/Abstract] AND united states[pl] AND (("' ~ $year ~ '/01/01"[PDat] : "' ~ $year ~ '/12/31"[PDat])))'
- }
- my @terms = "list5.txt".IO.lines.map: *.subst(:g, " ", "+").&uri_encode;
- my $id = 2135;
- for @terms -> $term {
- $id = $id + 1;
- say "Doing searches for $term";
- for 1966..2016 -> $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, "$id,$term,$year,$results-num\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement