homepage Welcome to WebmasterWorld Guest from 54.81.170.186
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
Actually executing JS within Perl?
huesv




msg:3808199
 10:29 pm on Dec 15, 2008 (gmt 0)

Here's my scenario:
There's an html page on my server that contains a link to a javascript source file (on another server). This javascript file returns/places an image in the html page from which the javascript file was src'd. Included javascript looks basically like this:

<script type="text/javascript"><!--
setup_all_parameters = "parameters";
//--></script>
<script type="text/javascript"
src="http://anotherserver.com/showImage.js">
</script>

That returns an image inline when viewing in a browser.

Within a Perl CGI on my server, I'd like to see the url for the image returned by the javascript described above. How can I execute/evaluate the javascript from within Perl to get the image url it returns?

LWP's get() just returns the source of the file without client-side processing. Can I pipe it to some virtual machine and get back the output?

 

janharders




msg:3808218
 11:01 pm on Dec 15, 2008 (gmt 0)

you can, but you propably don't want to, because it'll be painfull and insecure. And you probably don't have to: just figure out how the javascript works, then just parse the script with a regular expression and construct the imageurl you need.

huesv




msg:3808262
 11:42 pm on Dec 15, 2008 (gmt 0)

I can't figure out how the script assembles the url. It's Google's AdSense script for displaying ads. I need to do some processing based on the image ad urls it's returning to my site.

Here's the link to the code (some random website):i

<script type="text/javascript"><!--
google_ad_client = "pub-6666777788889999";
/* 728x90image */
google_ad_slot = "0541304911";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

If anyone has/can parsed it successfully, I'd love to know how.

[edited by: huesv at 12:26 am (utc) on Dec. 16, 2008]

janharders




msg:3808275
 12:19 am on Dec 16, 2008 (gmt 0)

you could try playing with the google adsense preview tool. If I recall correctly (been a few years since I wrote a script using it), there is an API that will return ads for any page or keyword in test-mode. use the preview tool, find the api (or find it by searching the web, it's been done before, look for adsense sandbox and similar keywords) and see wether it returns images as well (I know for sure it gives you those text-ads, image-ads hadn't been around when I played with it).

btw, you might want to remove the google-clientid etc from your post, it's not wise if it's yours and it's not nice if it's not yours.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved