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

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

Replies are listed 'Best First'.
Re^5: Loging into a website using javascript for login
by Kanji (Parson) on Sep 27, 2004 at 20:30 UTC

    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.