CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Processing JavaScriptLink by Perl .

 



ani.das00
New User

Mar 10, 2009, 2:39 PM

Post #1 of 2 (459 views)
Processing JavaScriptLink by Perl . Can't Post

I have a question about perl. I was trying to write a code which can access webpage in perl. I used the package CGI and LWP::simple. There’s one javascript link in that particular web page which I am trying to access. But when I do a get $url of that page and dump it to file, the website name after “JavaScriot:openlink” is missing. If I check the HTML code for the site in a browser (chorme), I can see it is there (And it opens the page on click on that link too).

<a href="JavaScript:openlink('http://www.mywebsite.com')">http://www.mywebsite.com</a>


Do any of you know if anything I am missing here? Or I should use any other package. I was trying CGI::Ajax (not sure thoug that it would help). But it seems not be installed in perl I am using.


1arryb
User

Mar 10, 2009, 3:19 PM

Post #2 of 2 (455 views)
Re: [ani.das00] Processing JavaScriptLink by Perl . [In reply to] Can't Post

Hi ani.das,

If all you need is the raw url so you can fetch it, try pre-processing your link. Perhaps something like:

Code
... 
if ($url =~ /a href=/) {
# It's a link.
if ( $url =~ 'JavaScript:openlink' ) {
# oops! java script. Parse the url from the argument to openlink().
$url =~ /\('([^']+)'\)/;
if ($1) {
$url = $1;
} else {
printf("Can't parse a url from $url\n");
}
}
}


Otherwise, you could try dealing with the javascript. I haven't done any of that, but you might take a look at this thread: http://www.perlmonks.org/?node_id=559996.

Cheers,

Larry

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives