0
我希望能够使用POST请求运行Web自动化脚本文件。下面是一个代码示例其中,例如,我想一个参数传递给该文件运行与用户指定的URL,而不是所示的.goto():通过POST请求将参数传递给JavaScript文件
var Nightmare = require('nightmare');
var nightmare = Nightmare({ show: true });
nightmare
.goto('https://duckduckgo.com')
.type('#search_form_input_homepage', 'github nightmare')
.click('#search_button_homepage')
.wait('#zero_click_wrapper .c-info__title a')
.evaluate(function() {
return document.querySelector('#zero_click_wrapper .c-info__title a').href;
})
.end()
.then(function (result) {
console.log(result);
})
.catch(function (error) {
console.error('Search failed:', error);
});
有什么办法来传递参数像这样直接导入.js文件?
总结这是接受一个参数并通过URL函数调用的函数。 –