in reply to Perl Mechanize - Header Help required.

Ask a question :)
#!/usr/bin/perl -- use strict; use warnings; use WWW::Mechanize 1.60; my $ua = WWW::Mechanize->new(autocheck => 1); my $url = 'http://documents-dds-ny.un.org/doc/UNDOC/GEN/N08/588/39/pdf +/N0858839.pdf?OpenElement'; my $file = 'test.pdf'; $ua->get($url,":content_file" => $file); $ua->dump_headers; if( $ua->is_html() ){ print qq!\nBUMMER, NOT PDF (is_html), DELETING "$file"\n\n!; unlink $file or die "DELETING FAILED $!"; } __END__ Cache-Control: no-cache Date: Sat, 30 Jan 2010 18:27:37 GMT Server: Lotus-Domino Content-Encoding: gzip Content-Length: 1483 Content-Type: text/html; charset=UTF-8 Expires: Tue, 01 Jan 1980 06:00:00 GMT Client-Date: Sat, 30 Jan 2010 18:27:30 GMT Client-Peer: 157.150.195.130:80 Client-Response-Num: 1 NtCoent-Length: 3406 BUMMER, NOT PDF (is_html), DELETING "test.pdf"

Replies are listed 'Best First'.
Re^2: Perl Mechanize - Header Help required.
by smilingsagar (Initiate) on Jan 31, 2010 at 02:40 UTC
    Even i got these headers. But how to handle these headers to get the pdf out.
      What pdf? The page returned is an error page, there is no pdf there.
        Thanks for your interest. Please follow these steps. go to 1. http://documents.un.org/welcome.asp?language=E 2. Go to simple search 3. in the text box - full text search type "President". 3. click on search. 4. results page follows. 5. click on any result. 6. Then a list of files appears. 7. click on the "pdf" result. 8. now the pdf file opens properly. but when i try this using the perl script this shows a error message. Please help me to get rid of this.
          A reply falls below the community's threshold of quality. You may see it by logging in.