我已经用Nightmare
抓了几天了,我的问题是加载页面并使用jQuery
包含.inject()
我写了这段代码;
const Nightmare = require ('nightmare');
var nightmare = new Nightmare ();
nightmare
.goto(url)
.inject('js', __dirname + /jquery.min.js')
.evaluate(fn(){
/*I need to extract some information from the page but when
I try to use the DOM object or the jQuery's '$' it shows
me an error saying that no document is defined*/
})
.wait(500);
PHPstorm(我使用JS和PHP编程的IDE)标记.goto()
和.inject()
并放下警告消息unresolved function or method .goto()
和unresolved function or method .inject()
我需要做什么来加载页面?也许没有足够的时间?
答案 0 :(得分:0)
我认为
.inject('js', __dirname + /jquery.min.js')'
应该是
.inject('js', __dirname + '/jquery.min.js')'
您缺少报价