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