Phantomjs代码帮助从本地驱动器中的另一个外部脚本获取搜索值

Phantomjs代码帮助从本地驱动器中的另一个外部脚本获取搜索值,phantomjs,Phantomjs,我的问题是:无法将这两个脚本合并并作为一个脚本执行..我尝试了很多解析错误..请帮助我在一个脚本中成功执行它 a、 )first(childprocess.js)--它输出搜索文本,输入到脚本google.js的搜索框中 var process = require("child_process") var execFile = process.execFile execFile("python", ["C:\\PhantomJS\\phantomjs\\pyt.py"], null,

我的问题是:无法将这两个脚本合并并作为一个脚本执行..我尝试了很多解析错误..请帮助我在一个脚本中成功执行它

a、 )first(childprocess.js)--它输出搜索文本,输入到脚本google.js的搜索框中

  var process = require("child_process")
  var execFile = process.execFile

 execFile("python", ["C:\\PhantomJS\\phantomjs\\pyt.py"], null, function (err, stdout, stderr) {
  var a = JSON.stringify(stdout);
  var t = {};
  t.substr = a.substr(1,20);
  var ocr = t.substr;
  console.log(ocr);
  })
  setTimeout(function (ocrad) {
  phantom.exit(1)
  }, 2000)

b、 )第二个脚本(google.js)--它将获取搜索值并截图

   var page = require("webpage").create();
   var homePage = "http://www.google.com/";

        page.open(homePage);
        page.onLoadFinished = function(status) {
        var url = page.url;

       console.log("Status:  " + status);
       console.log("Loaded:  " + url);

       if (url === homePage) {
       page.includeJs("http://code.jquery.com/jquery-1.8.3.min.js", function() {
  console.log("Loaded jQuery!");
  page.evaluate(function() {
    var searchBox = $("#.lst");
    var stringbox =$("#text_bost");
    var searchForm = $("form1");
    //value to be got from first script
    searchBox.val("first script output value"); 
    stringBox.val("oracleapps");
    searchForm.submit();
     });
    });
    } else {
    page.render("results.png");
   phantom.exit();
 }
 };

我不确定我是否理解问题所在。您是否可以编辑您的问题以包含合并失败的代码。请添加输出、错误和您希望它如何运行的描述。感谢Artom B我已经完成了家庭作业…上面给出的两个脚本运行完全正常。。我想合并它,并有一个程序…以便获得所需的页面呈现给我!!我不确定我是否理解问题所在。您是否可以编辑您的问题以包含合并失败的代码。请添加输出、错误和您希望它如何运行的描述。感谢Artom B我已经完成了家庭作业…上面给出的两个脚本运行完全正常。。我想合并它,并有一个程序…以便获得所需的页面呈现给我!!