Advertisement
Guest User

Untitled

a guest
Sep 7th, 2017
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. use WWW;
  2. use DOM::Tiny;
  3. use URI::Encode;
  4.  
  5. constant URL = 'https://www.ncbi.nlm.nih.gov/pubmed';
  6. my $fh = open :w, 'results7.txt';
  7. constant OUT_FILE = 'results7.txt'.IO;
  8.  
  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. sub make-term ($year) {
  13. '( "Alzheimer Disease"[Title/Abstract] AND united states[pl] AND (("' ~ $year ~ '/01/01"[PDat] : "' ~ $year ~ '/12/31"[PDat])))'
  14. }
  15.  
  16. #my @terms = "list7.txt".IO.lines.map: *.subst(:g, " ", "+").&uri_encode;
  17. my $id = 1183;
  18.  
  19. my $term = "Alzheimer";
  20. #for @terms -> $term {
  21. $id = $id + 1;
  22. say "Doing searches for Cancer";
  23. for 2015..2016 -> $year {
  24. print "\t...year $year ";
  25. my $results-num = DOM::Tiny.parse(post URL, term => make-term $year)
  26. .at('meta[name="ncbi_resultcount"]').attr: 'content';
  27. say "Found $results-num results";
  28.  
  29. OUT_FILE.spurt: :append, "$id,$term,$year,$results-num\n";
  30. }
  31. #}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement