Automatically exported from code.google.com/p/planningalerts
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

56 rindas
1.1 KiB

  1. #!/usr/bin/perl -w
  2. use strict;
  3. use LWP::Simple;
  4. use File::Temp qw(tempfile);
  5. use POSIX;
  6. use CGI;
  7. my $cgi = new CGI;
  8. my $year = $cgi->param("year");
  9. my $month = $cgi->param("month");
  10. my $day = $cgi->param("day");
  11. unless (defined $year && defined $month && defined $day) {
  12. print <<ERROR;
  13. Content-type: text/plain
  14. Need year, month, day parameters
  15. ERROR
  16. exit 0;
  17. }
  18. my $html = get('http://www.brentwood-council.gov.uk/index.php?cid=573');
  19. my $date = strftime("%d %B %Y", 0, 0, 0, $day, $month-1, $year-1900);
  20. # quick and dirty
  21. my ($url) = ($html =~ /(http:\/\/[^"]*\.pdf)[^<]*(<[^>]*>)*[^<]*$date/);
  22. unless (defined $url) {
  23. print <<NIL;
  24. Content-type: text/xml
  25. <?xml version="1.0" encoding="UTF-8"?>
  26. <planning>
  27. <authority_name>Brentwood Borough Council</authority_name>
  28. <authority_short_name>Brentwood</authority_short_name>
  29. <applications>
  30. </applications>
  31. </planning>
  32. NIL
  33. exit 0;
  34. }
  35. my $dmy = sprintf("%02d/%02d/%04d", $day, $month, $year);
  36. my ($fh, $filename) = tempfile(SUFFIX => ".pdf");
  37. print $fh get($url);
  38. close($fh);
  39. print "Content-type: text/xml\n\n";
  40. system "./Brentwood.pl", $filename, $url, $dmy;
  41. unlink $filename;