Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: In a Web Page forms are displayed as empty

by jesuashok (Curate)
on May 04, 2007 at 06:30 UTC ( [id://613520]=note: print w/replies, xml ) Need Help??


in reply to Re: In a Web Page forms are displayed as empty
in thread In a Web Page forms are displayed as empty

Hi Preceptor,

Sorry for the delayed comment.
As you suggested I used $mech -> content. I got the following output.

#!/usr/bin/perl use WWW::Mechanize ; use LWP::Debug qw(+); use strict; use warnings; use Data::Dumper; my $mech = WWW::Mechanize->new ; $mech->proxy(['http','ftp'], 'http://63.117.9.150:8080/'); #Fetch URL or Die Tryin' $mech ->get("http://<application_ip>:8082/metrica_root/Login") ; if ( $mech ->success ) { print "Connection Success ", $mech ->res->sta +tus_line, "\n"; } else { print "Status :" , $mech ->res->status_line , + "\n"; } my @webforms = $mech->forms(); print Dumper [ @webforms ]; print "Trying to print the content ......\n"; $mech->content; foreach my $form (@webforms) { my @inputfields = $form->param; foreach my $inputfield (@inputfields) { print Dumper [ $inputfield ]; } print Dumper [ $form ]; }
Output :- LWP::UserAgent::new: () LWP::UserAgent::proxy: ARRAY(0x1bf0e28) http://63.117.9.150:8080/ LWP::UserAgent::proxy: http http://63.117.9.150:8080/ LWP::UserAgent::proxy: ftp http://63.117.9.150:8080/ LWP::UserAgent::request: () HTTP::Cookies::add_cookie_header: Checking 155.226.230.173 for cookies HTTP::Cookies::add_cookie_header: Checking .226.230.173 for cookies HTTP::Cookies::add_cookie_header: Checking 226.230.173 for cookies HTTP::Cookies::add_cookie_header: Checking .230.173 for cookies HTTP::Cookies::add_cookie_header: Checking 230.173 for cookies HTTP::Cookies::add_cookie_header: Checking .173 for cookies LWP::UserAgent::send_request: GET http://155.226.230.173:8082/metrica_ +root/Login LWP::UserAgent::_need_proxy: Proxied to http://63.117.9.150:8080/ LWP::Protocol::http::request: () LWP::Protocol::collect: read 266 bytes LWP::Protocol::collect: read 301 bytes HTTP::Cookies::extract_cookies: Set cookie JSESSIONID => 0000000000000 +01a49444c3 a687474702f52657150726f636573736f723a312e30000000000000010000000000000 +0ac0001020 0000000103135352e3232362e3233302e31373300c39300000000004900504d4300000 +0000000001 a49444c3a687474702f52657150726f636573736f723a312e300020200000000974635 +f696e73743 1002020200000000d2f746f6d636174345f706f6100000000000000035649530300000 +0050005070 17f0000000000000000000008000000005649530000000001000000140000000000010 +0010000000 00001010900000000_2925080BF3F637D984812BF731798941 LWP::UserAgent::request: Simple response: OK Connection Success 200 OK $VAR1 = []; Trying to print the content ......
I don't have any clues to move further on this. I am expecting your valid inputs on the same.

Replies are listed 'Best First'.
Re^3: In a Web Page forms are displayed as empty
by marto (Cardinal) on May 04, 2007 at 09:07 UTC
    Hi jesuashok,

    I had a hunch that the pages in question are generated by JavaScript using 'document.write', so I /msg'd you to confirm this. I have seen some pages that use document.write to output html. Let us take for a basic example the following html page:
    <html> <head> <title>Bad Example</title> </head> <body> <script> document.write('<H1>JavaScript made me do it!</H1>') </script> </body> </html>
    Now the following Perl code:
    #!/usr/bin/perl use strict; use warnings; use WWW::Mechanize; my $mech = WWW::Mechanize->new; $mech->get('http://yourserverhere/test.html'); print $mech->content( format => "text" );
    Which outputs: "Bad Example". Why? Because "Please note that Mech does NOT support JavaScript. Please check the FAQ in WWW::Mechanize::FAQ for more.".

    You can use Win32::IE::Mechanize or Mozilla::Mechanize or alike to control a browser which does know how to deal with JavaScript. This is another reason to always refer to the documentation.

    Update: Excuse the lack of error checking in the Perl script above, I wanted to get this post to you ASAP and I have to attend a project meeting.

    Hope this helps

    Martin

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://613520]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-19 06:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found