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, 'results7.txt';
- constant OUT_FILE = 'results7.txt'.IO;
- #sub make-term (:$term, :$year) {
- #'(' ~ $term ~ '[Title/Abstract] AND united states[pl] AND (("' ~ $year ~ '/01/01"[PDat] : "' ~ $year ~ '/12/31"[PDat])))'
- #}
- sub make-term ($year) {
- '( "Alzheimer Disease"[Title/Abstract] AND united states[pl] AND (("' ~ $year ~ '/01/01"[PDat] : "' ~ $year ~ '/12/31"[PDat])))'
- }
- #my @terms = "list7.txt".IO.lines.map: *.subst(:g, " ", "+").&uri_encode;
- my $id = 1183;
- my $term = "Alzheimer";
- #for @terms -> $term {
- $id = $id + 1;
- say "Doing searches for Cancer";
- for 2015..2016 -> $year {
- print "\t...year $year ";
- my $results-num = DOM::Tiny.parse(post URL, term => make-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