Automatically exported from code.google.com/p/planningalerts
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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.glasgow.gov.uk/en/Business/Planning_Development/DevelopmentControl/Sitehistorysearches/');
  19. my $date = sprintf("%02d/%02d/%02d", $day, $month, $year % 100);
  20. # quick and dirty
  21. my ($url) = ($html =~ /href="(\/[^"]*\.pdf)[^<]*[0-9]{2}\/[0-9]{2}\/[0-9]{2} - $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>Glasgow City Council</authority_name>
  28. <authority_short_name>Glasgow</authority_short_name>
  29. <applications>
  30. </applications>
  31. </planning>
  32. NIL
  33. exit 0;
  34. }
  35. my $absurl = "http://www.glasgow.gov.uk$url";
  36. my ($fh, $filename) = tempfile(SUFFIX => ".pdf");
  37. print $fh get($absurl);
  38. close($fh);
  39. print "Content-type: text/xml\n\n";
  40. system "./Glasgow.pl", $filename, $absurl;
  41. unlink $filename;