Invoking a script from another script

Hi,

Apologies if this is covered, but I can't seem to find anything in the docs or posts. Can you invoke a script from another script, and if so can you post a couple of examples? Thanks!

John

A bit more detail: I've got several common functions that I've isolated in scripts and had previously called them after the appropriate page was scraped.

Now the application is more complex, and I've got a couple of scrapers where every scraper page is called from a script based on custom logic. I also need that logic to determine when to call the correct script to post back the results; the challenge is that i'd love to call them from the master controlling script.

What i'm really trying to do is separate my data access/model scripts from my controller scripts to avoid repeating the same code. Any suggestions? It would be really easy to do if I could just call a script from another script. Thanks!

Invoking a script from another script

Excellent! Please just let us know if you run into any trouble with it.

Best,

Todd

Invoking a script from another script

AWESOME!!! Thanks for adding that method - very handy, works great, and it saved me a ton of time.

Cheers,

John

Invoking a script from another script

Hi John,

You're in luck--I thought of a fairly quick and easy way to implement this. Upgrade to version 2.7.2.1a of screen-scraper to get the change (see this FAQ if you're told there isn't an update: http://community.screen-scraper.com/faq#80n867).

The method is pretty simple:

session.executeScript( "My Script" );

The usual "alpha version" caveats apply--this hasn't been tested thoroughly, so you might encounter some weirdness. Either way, please let us know how it goes.

Thanks,

Todd

Invoking a script from another script

Hi John,

Thanks for the posting. We've had requests for this in the past, but haven't yet implemented it. Given that you've just requested it again, however, I'll see about bumping it up in the priority queue.

As an alternative, when we have code we want to reuse, we generally encapsulate it in compiled Java .jar files. If you know Java, this is probably the best route. We've also implemented web service type approaches where you encapsulate your code in a web-accessible script (e.g., a PHP file), then invoke it from a scrapeable file in screen-scraper.

Kind regards,

Todd Wilson