我有以下Javascript代码,以便从“incoming.shopify.com”中提取“当前订单费率”。但是,当我拉动源HTML时,源HTML很长,以至于它没有在网站上包含“Order / Minute”图。我想从源HTML中提取“Order / Minute”图,并使用console.log将其打印出来。
var wd = require('wd');
var fs = require('fs');
// defaults
var browser_name = 'firefox';
wd.configureHttp({
timeout: 60000,
retries: 3,
retryDelay: 100
});
var browser = wd.promiseChainRemote();
var p = { promise: null };
/*** Expose Components to other files ***/
exports.browser = browser;
exports.p = p;
// setup
p.promise = browser
.init({ browserName: browser_name })
.setAsyncScriptTimeout(30000)
p.promise = p.promise
.get("incoming.shopify.com")
.sleep(1500)
.source(function(err, source_html){
var FindNumberArr = source_html.split('<div class="counter__count" id="volume_rate">');
var Result1 = FindNumberArr.slice(1);
var FindNumberArr2 = Result1.split("</div>");
var Result2 = FindNumberArr2.slice(0);
console.print(Result2);
})
p.promise = p.promise
.quit()
.done();