Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Loging into a website using javascript for login

by Kanji (Parson)
on Sep 27, 2004 at 16:30 UTC ( [id://394234]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Loging into a website using javascript for login
in thread Loging into a website using javascript for login

A few comments...

If the META refresh is directing you to 'https://secure2.playboy.com/security/cookieGenerator.do', why are you get()ing 'https://secure2.playboy.com/gateway/gateway.do '?

If you meant after hitting 'cookieGenerator.do' you are then redirected to 'gateway.do ', are you sure that trailing space is supposed to be there?

Have you looked at HTTP::Recorder (alt.)? It could make your life a whole lot easier. :-)

    --k.


  • Comment on Re^3: Loging into a website using javascript for login

Replies are listed 'Best First'.
Re^4: Loging into a website using javascript for login
by homer123 (Initiate) on Sep 27, 2004 at 18:05 UTC
    Hi
    Thanks for the tip. I was able to figure that out the hard way by carefully seeing where by browser was going. I didnt know about the META tag. I am now able to download the file 'https://secure2.playboy.com/security/cookieGenerator.do'
    Once again this file is a redirect to
    https://secure2.spicetv.com/security/cookieGenerator.do
    but with a lot of cookie information added at the end. So I am trying to get the value of the "content" attribute of the "meta" tag.
    I am now trying to parse the html file using HTML::TokeParserL::Simple. The trouble is the html file has the first few lines as the new line character and each line after that has a new line character. The HTML::TokerParser::Simple is choking on the malformed (??) html. So I am trying to remove the lines which have only a new line character (^M) and remove the ^M at the end of each line. Since this is my first time with perl I am struggling with this simple task.
    Any help or code sample to strip off lines with only a new line character and the new line character at the end of each line is appreciated. I am trying to use chomp but dont know how to loop through the entire output of mech->content
    If I clean up the html file by hand and then run the following script
    my $p = HTML::TokeParser::Simple->new( $html ); my $token = $p->get_token; my $tag = "meta"; my $att = "content"; if ( $token->is_tag($tag) ) { print "There is a $tag tag\n" }; my $att_value = $token->get_attr($att); print "The value of the $att attribute of the $tag tag is $att_value \ +n\n\n\n"; my $url = substr($att_value,6); print $url,"\n";

    Iam able to get the info I need but cleaning up the html file is the problem
    Thanks

      Actually, there's no need to write your own parser to get at that URL: LWP::UserAgent, which WWW::Mechanize is an extension of, does it for you!

      # UNTESTED; USE AT YOUR OWN PERIL :-) my $response = $mech->submit_form( form_name => 'loginForm', # ... ); # Follow HTTP or META refreshes. if (my $url = $response->header('Refresh')) { $url =~ s/^\d+;url=//i; $mech->get($url); }

      There may even be way to get LWP::UA or WWW::Mech to automatically follow along, but I haven't delved into the documentation to see although I did stumble across a WWW::Mechanize wishlist item that you may want to keep your eye on.

          --k.


Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2024-04-18 12:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found