Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Solution for your problem with LWP, frames, login, and parent.main.location.replace()

by arhuman (Vicar)
on Mar 02, 2001 at 23:32 UTC ( #61863=note: print w/replies, xml ) Need Help??


in reply to Problem with LWP, frames, login, and parent.main.location.replace()


I've slightly modified (messed) your code and it works now...
Or at least it seems to work,
(My german doesn't allow me to be 100% affirmative)
I've printed the last reached page for you can check it.

Take note of the 'id' parameter passed on the url when you connect to the site.
It's a 'session id', It changes with each connexion.
when you use an 'id' that you got long before (and the password associated to this 'session id' the session is no longer valid, and you get the message telling 'you haven't been connected for too long' (Or something like that, my german isn't what it was supposed to be.))

BTW your User Agent is not a valid one
(something like :
"Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)"
is more common)
and in this case is useless.

I've leaved the debugging code (printing MATCH)
to show you that the id value changes every time...

the regex are ugly (please japhy don't hit me hard) but were just done to test it. In a real code you'll have to harden them...
use LWP::UserAgent; my $hdrs = new HTTP::Headers('Accept' => 'text/plain', 'User-Agent' => + 'IE/5.0'); my $ua = new LWP::UserAgent; $page=get_url('http://www.friendscout.de'); if ($page=~ /content="\d+;url=([^"]+)/m) { print "\n\n*********MATCH($1)*******\n\n"; $page=get_url("http://www.friendscout.de/$1"); } else { print "redirect not found !"; } if ($page=~ /location.href="([^"]+)"/s) { print "\n\n*********MATCH2($1)*******\n\n"; $page=get_url("http://www.friendscout.de/$1&page=loginp&nickname=J +ohnSmith&password=test&x=0&y +=0"); } else { print "redirect not found !"; } print $page; if ($page=~ /main.location.replace\("([^"]+)"/s) { print "\n\n*********MATCH3($1)*******\n\n"; $page=get_url("http://www.friendscout.de/$1&page=loginp&nickname=J +ohnSmith&password=test&x=0&y +=0"); } else { print "redirect not found !"; } print $page; sub get_url() { my $url2get = shift @_; my $url = new URI::URL($url2get); my $req = new HTTP::Request('GET', $url, $hdrs); my $resp = $ua->request($req); if ($resp->is_success) { return $resp->content;} else { return $resp->message;} }
  • Comment on Solution for your problem with LWP, frames, login, and parent.main.location.replace()
  • Download Code

Replies are listed 'Best First'.
Re: Re: Problem with LWP, frames, login, and parent.main.location.replace()
by BinBerliner (Novice) on Mar 03, 2001 at 00:13 UTC
    Okay. So now I extract the ID from a previous page containing javascript and paste it into the subsequent URLs that I want to get, and... it works! Looks like the ID does change for every session. Thanks for clearing this up guys. I know nothing about server side CGI development but by fiddling on the client side then slowly but surely I'm learning more about the sneaky things that the server side can get up to... :-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2020-10-31 23:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (291 votes). Check out past polls.

    Notices?