我正在學習如何從我的php腳本運行iMacros,以便PHP腳本調用iMacros瀏覽器會話並傳遞我擁有的任何變量(例如url和宏名稱)。然後,iMacros會話運行iMacro,在宏完成運行後,它將生成的html頁面傳遞迴PHP腳本並關閉自身。無論如何,在理想的世界裏。我的iMacro腳本不在我的PHP腳本中運行。爲什麼?
這裏是iMacros的調用腳本:
<?php
require 'src/iimfx.class.php';
$iim = new imacros();
$vars = array();
$iim->play($vars,'grab_data.iim');
?>
但是當我運行cmd.exe的從[命令行]上WAMP這個劇本,我得到這個:
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。大拇指爲這個問題,讓別人可以看到它。 – macroscripts 2013-02-26 20:53:23