run javascript inside php?
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开发者_Python百科 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.
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.
There is also a php extensions that embed javascript engines
- Spidermonkey JavaScript engine for PHP, embeds Mozilla's Javascript engine Spidermonkey in PHP. by Christophe Robin
- V8 Javascript Engine for PHP, embeds the Google's V8 Javascript Engine into PHP by Jani Taskinen
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.
精彩评论