Guest User

Untitled

a guest
Dec 16th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. #!/usr/bin/env perl6
  2. #
  3.  
  4. use LWP::Simple;
  5. use URI::Escape;
  6. use Cro::HTTP::Client;
  7. use LibCurl::Easy;
  8. use Grammar::Debugger;
  9. use HTML::Parser::XML;
  10. use DOM::Tiny;
  11.  
  12. grammar Docdata {
  13. token TOP {<record>+}
  14.  
  15. token record { <cell>||<not_comp> }
  16. token cell {\s*'<TD'\s*<align>'>'\s*<content>'</TD>'\s*}
  17. token align {<-[>]>*}
  18. token content {\s*<date_time_form>*[<!before '</TD>'>.]*}
  19.  
  20.  
  21. token date_time_form {<date>||<time>||<form>}
  22. rule date {<month>\s<day>\s<year>}
  23. token time {<{[0 ... 23]».fmt('%02d')}>':'<{[0 ... 60]».fmt('%02d')}>':'<{[0 ... 60]».fmt('%02d')}>\s'ET'}
  24.  
  25.  
  26. token month {'Jan'||'Feb'||'Mar'||'Apr'||'May'||'Jun'||'Jul'||'Aug'||'Sep'||'Oct'||'Nov'||'Dec'}
  27. token day {<{[1 ... 31]}>}
  28. token year {<{[1900 ... 2100]}>}
  29. token form {\s*'<FORM'.*'</FORM>'\s*}
  30. token link {[<!before '</FORM>'>.]*}
  31. token not_comp {\V*\v}
  32.  
  33.  
  34. }
  35.  
  36. my %formdata = lang => "EN", page_no => "1", company_search => "Wells Fargo", document_selection => "0", industry_group => "A", FromMonth => "05", FromDate => "24", FromYear => "2017", ToMonth => "11", ToDate => "24", ToYear => "2017", Variable => "Issuer", Search => "Search";
  37.  
  38.  
  39. my $resp = await Cro::HTTP::Client.post: "http://www.sedar.com/FindCompanyDocuments.do", headers => [ User-agent => 'Mozilla/5.0 (X11; Fedora; Linux x86_64)'], content-type => 'application/x-www-form-urlencoded', body => %formdata;
  40.  
  41.  
  42. my $content = await $resp.body;
  43. my $dom = DOM::Tiny.parse($content);
  44. my $table = $dom.at('table');
  45. say $table.all-text;
Add Comment
Please, Sign In to add comment