1

I need to call arbitrary javascript functions from a page I download with a cURL session inside a php script. For example, on the site x4x4x.tk, I need to call updateLocation() (search for "updateLocation(this)" in the source). I can't have the script pop open a browser window and do it there, it needs to be done entirely from the command line.

I found an extension called v8js that looks like it would do what I need, but it requires php 5.3.3. The server the script will run on uses php 5.2.6-1 and I'm not in a position where I can update the server.

I found the extensions php-js and j4p5 and they look like they'll do what I want, but I wanted to check on here and see if anyone's tried to do anything like this before.

3
  • there are easier ways to interact with a proxy than this. Commented Jun 15, 2011 at 22:06
  • try out those libs you mention. if they work for you, add that as an answer and accept it. you might want to link to those for future visitors. Commented Jun 16, 2011 at 7:02
  • php-js is quite the opposite of what you're asking Commented Jul 1, 2011 at 12:50

3 Answers 3

5

JavaScript - Client Side
PHP - Server Side.

Best guess? Either translate the code, or open a browser window for the client to execute it. otherwise, you're not going to have a fun time getting a javascript file to execute via php/cURL.

Sign up to request clarification or add additional context in comments.

2 Comments

The purpose of the script is to request some random website and run random functions off of it. I'm not going to have any idea of what the functions are. If they were always the same I could just translate it, but it looks like I'm going to have have... "fun"
Server Side Javascript is growing each day, so please dont slapdown the OP with the old JS is client side.
4

There is also a php extensions that embed javascript engines

Comments

0

php/curl cant execute/run javascript. You could go with a macro chained to php. Check imacros for that or selenium. Both run a browser able to execute and parse javascript. Maybe hack the output and make it run whatever javascript function you want but it's a long shot. Anyways, hope it gets you to the right direction, you could go there (selenium, imacros website) and ask further.

1 Comment

Thanks, I'll check those out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.