Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

execute javascript from perl

Status
Not open for further replies.

umjaco6

Programmer
Sep 23, 2001
3
CA
Hi,

Platform: Apache, Linux, Perl 5.*

I am attempting to create a remote login for ebay.

How Ebays Login Works (from your browser):
1. You fill out the form and submit it.
2. Ebay returns and HTML page the contains javascript functions.
3. When the page is loaded in your browser the javascript is executed. These javascript functions
-set the cookie on your browser (required by Ebay)
-and submit a another form to send you to the user page

What I have working:
My perl script fills out the login form at ebay and returns the html page mentioned in number 2. What I need to know is how can I execute the javascript functions on this html page?

My perl code:
use LWP::UserAgent;
use HTTP::Request::Common;
my $ua = LWP::UserAgent->new;
$ua->env_proxy;
use HTTP::Cookies; $ua->cookie_jar(HTTP::Cookies->new);
$ua->request(GET " # to set cookies
my $r=$ua->request(POST " [
"MfcISAPICommand" => "SignInWelcome", # hidden
"siteid" => "0", # hidden
"co_partnerId" => "2", # hidden
"UsingSSL" => "0", # hidden
#more parameters sent here
"pageType" => "174", # hidden
"userid" => "userid", # text
"pass" => "password", # password
],
Referer => ");

$content=$r->content;
#$content now contains the html page
#with the javascript functions.
#how do I execute the javascript functions
#in $content?


SAMPLE HTML PAGE RETURN IN $CONTENT
______________________________________
<HTML>
<SCRIPT Lanuage=&quot;text/javascript&quot;>
<!--
function writecookie(){
;//ebay cookie is set here
}
//-->
</SCRIPT>
<BODY>

<FORM action=&quot;ebayactionform&quot; method=post name=f1>
<INPUT TYPE=&quot;hidden&quot; Name=&quot;ebaysignin&quot; value=&quot;in&quot;>
</FORM>
<SCRIPT Language=&quot;text/javascript&quot;>
<!--

writecookie();

//the html page return also
//contains a form that is
//submitted using javascript

document.f1.submit();
//-->
</BODY>
</HTML>

______________________________

Does any one have any suggestions?

Thanks Janie
 
Why not set the cookie and create the new form from within PERL itself rather than have the extra overhead of Javascript?
Keith
 
Hi,

Doesn't ebay have to set the cookie in order for ebay to read the cookie?

I can set the cookie but then the server will identify that cookie with instead of with and as a result ebay will not be able to read the cookie???

Janie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top