Advertisement
Guest User

Untitled

a guest
Aug 29th, 2017
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. use WWW;
  2. use DOM::Tiny;
  3.  
  4. constant URL = 'https://www.ncbi.nlm.nih.gov/pubmed';
  5. my $fh = open :w, 'output.txt';
  6. constant OUT_FILE = 'results.txt'.IO;
  7.  
  8. #sub make-term (:$term, :$year) { #'(' ~ $term ~ ' AND (("' ~ $year ~ '/01/01"[PDat] : "' ~ $year ~ '/12/31"[PDat])))' }
  9. sub make-term (:$term, :$year) {
  10. '(' ~ $term ~ '[Title/Abstract] AND united states[pl] AND (("' ~ $year ~ '/01/01"[PDat] : "' ~ $year ~ '/12/31"[PDat])))'
  11. }
  12.  
  13. my @terms = "list.txt".IO.lines;
  14.  
  15. for @terms -> $term {
  16. say "Doing searches for $term";
  17. for 1990..1991 -> $year {
  18. print "\t...year $year ";
  19. my $results-num = DOM::Tiny.parse(post URL, term => make-term :$term, :$year)
  20. .at('meta[name="ncbi_resultcount"]').attr: 'content';
  21. say "Found $results-num results";
  22. OUT_FILE.spurt: :append, "$term,$year,$results-num\n";
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement