【问题标题】:My iMacro script(s) doesnt run inside my PHP script. Why?我的 iMacro 脚本不在我的 PHP 脚本中运行。为什么?
【发布时间】:2013-02-25 23:42:10
【问题描述】:

我正在学习如何从我的 php 脚本运行 iMacros,以便 PHP 脚本调用 iMacros 浏览器会话并传递我拥有的任何变量(例如 url 和宏名称)。然后 iMacros 会话运行 iMacro,在宏运行完成后,它会将生成的 html 页面传回 PHP 脚本并自行关闭。无论如何,在一个理想的世界里。

这是 iMacros 调用脚本:

<?php

require 'src/iimfx.class.php';

$iim = new imacros();

$vars = array();

$iim->play($vars,'grab_data.iim');


?>

但是当我从 WAMP 上的 cmd.exe [命令行] 运行这个脚本时,我得到了这个:

New imacros session started!
Using Proxy: MY_PROXY_IP:MY_PROXY_PORT
-runner -fx -fxProfile default
--------------------------------------------------------
Setting Value IP => MY_PROXY_IP
Setting Value port => MY_PROXY_PORT
Playing Macro proxy.iim
--------MACRO ERROR!-------------------
 ERROR: Browser was not started. iimInit() failed?
--------------------------------------------------------
Playing Macro grab_google.iim
--------MACRO ERROR!-------------------
 ERROR: Browser was not started. iimInit() failed?

附: MY_PROXY_IP 和 MY_PROXY_PORT 在上面的错误消息和 iimfx.class.php 中都替换为实际数字。

这是 iimfx.class.php 的代码:

<?php

class imacros {
    function __construct($proxyip = 'MY_PROXY_IP', $proxyport = 'MY_PROXY_PORT', $silent = false, $noexit = false) {

        echo "--------------------------------------\nNew imacros session started!\nUsing Proxy: $proxyip:$proxyport\n";
        $this->proxyip = $proxyip;
        $this->proxyport = $proxyport;

        if (empty ( $this->proxyip ))
            echo "NO PROXY!!\n";

        $this->noexit = $noexit;
        $this->fso = new COM ( 'Scripting.FileSystemObject' );
        $this->fso = NULL;

        $this->iim = new COM ( "imacros" );

        $toexec = "-runner -fx -fxProfile default";

        if ($silent === true)
            $toexec .= " -silent";

        if ($noexit === true)
            $toexec .= " -noexit";

        echo $toexec . "\n";

        $this->iim->iimInit ( $toexec );

        if (! empty ( $this->proxyip )) {
            $dvars ['IP'] = $this->proxyip;
            $dvars ['port'] = $this->proxyport;
            $this->play ( $dvars, 'proxy.iim' );
        }
    }

    function __destruct() {
        if ($this->noexit === false)
            $this->iim->iimExit ();
    }

    function play($immvars = '', $macro) {

        echo "--------------------------------------------------------\n";

        if (is_array ( $immvars )) {
            foreach ( $immvars as $key => $value ) {
                echo "Setting Value $key => $value\n";
                $this->iim->iimSet ( "-var_" . $key, $value );
            }
        }

        echo "Playing Macro $macro\n";
        $s = $this->iim->iimPlay ( $macro );

        if($s>0){
            echo "Macro successfully played!\n";
        }else{
            echo "--------MACRO ERROR!-------------------\n ERROR: " . $this->getLastError() . "\n";
        }
        return $s;
    }

    // This function retrieves extracts in your iMacros script if you have any. 
    function getLastExtract($num) {
        return $this->iim->iimGetLastExtract ( $num );
    }

    // Returns the last error :)
    function getLastError(){
        return $this->iim->iimGetLastError();
    }

    // Enables/disables images
    function setImages($images = 1) { // 1 = on 2 = off

        $dvars ['images'] = $images;
        $this->play ( $dvars, 'images.iim' );

    }

    // Enables or disables adblockplus
    function enableABP($status = true){

        $dvars['status'] = $status;
        $this->play ( $dvars, 'abp.iim' );

    }

}

?>

我在这里缺少什么吗? 我在所有这些过程中运行了 iimRunner.exe [在运行脚本之前手动启动],并且我有 iMacros Browser V8+。 此外,我的 grab_data.iim 和所有其他必需的 .iim 与试图调用它们并执行它们的 php 脚本位于同一位置。

我们将不胜感激任何形式的帮助和/或朝着正确方向前进! 提前致谢。

【问题讨论】:

  • 我觉得这个问题很有趣,我做 iMacros 但不是在 PHP 中。为这个问题点赞,以便其他人可以看到。

标签: php imacros web-scripting


【解决方案1】:

你必须在启动脚本之前启动 immrunner =)

http://wiki.imacros.net/iimRunner

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-15
    • 2015-07-26
    • 1970-01-01
    • 2011-11-26
    • 2017-04-15
    • 1970-01-01
    • 1970-01-01
    • 2010-09-05
    相关资源
    最近更新 更多