Phantom JS从本地文件或字符串加载url

时间:2014-07-04 01:57:20

标签: javascript php jquery phantomjs

我需要在URL上运行Phantomjs,但是在本地保存的页面上没有托管在网络上只存在于txt文件或字符串中,然后我需要返回一个图像数组:所以我有两个问题。

我的PHP函数:

$result = shell_exec('phantomjs myscript.js');

  1. 我可以返回一个数组,还是只做console.log(array[i]);
  2. 如何将html注入page.open或如何加载本地页面?
  3. myscript.js

    var page = require('webpage').create();
        page.viewportSize = { width: 320, height: 480 };
        page.open('somelocalpage.php', function (status) {
            if (status !== 'success') {
                console.log('Unable to access the network!');
            } else {
                page.evaluate(function () {
                   //find all images:
                   //return array.
    
                });
    
    
            }
            phantom.exit();
        });
    

0 个答案:

没有答案
相关问题