Guest User

Untitled

a guest
Sep 4th, 2017
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. use WWW;
  2. use DOM::Tiny;
  3. use Text::CSV;
  4. use URI::Encode;
  5. use HTTP::UserAgent;
  6.  
  7. my $fh = open :w, 'results3.txt';
  8. constant OUT_FILE = 'results3.txt'.IO;
  9.  
  10. my @terms = "list3.txt".IO.lines.map: *.subst(:g, " ", "+").&uri_encode;
  11. my $id = 1114;
  12.  
  13. for @terms -> $term {
  14. $id = $id + 1;
  15. say "Searching for: $term";
  16. for 1990..1991 -> $year {
  17. print "\t...year $year ";
  18. "temp".IO.spurt: get "https://patents.google.com/xhr/query?url=q%3D$term%26country%3DUS%26before%3D{$year}0101%26after%3D{$year}1231&exp=&download=true", User-Agent => 'Mozilla/5.0';
  19. my $results-num = csv(:in<temp>).elems - 2;
  20. say $results-num;
  21. $fh.spurt: :append, "$term,$year,$results-num\n";
  22. sleep(9.rand);
  23. }
  24. }
  25. $fh.close;
Advertisement
Add Comment
Please, Sign In to add comment