在PhantomJS中使用jQuery DOM选择器语法? [英] Use jQuery DOM selector syntax in PhantomJS?
问题描述
我正在学习PhantomJS,想知道是否有可能在PhantomJS运行的JS文件中使用jQuery DOM选择器?我在github上看到了一个简短的示例,似乎表明了这一点:
I'm learning PhantomJS and wondered if it's possible to use jQuery DOM selectors in the JS files PhantomJS runs? I've seen a short example on github that appears to indicate this:
如果您在顶部查看run-qunit.js文件,看来状态可以使用jQuery DOM选择器作为参数.但是当我这样做时会出现错误-不知道这是我的语法还是因为Phantom不了解jQuery,所以我想我首先要问一下PhantomJS/jQuery关系.
If you look at the run-qunit.js file at the top it seems state you can use jQuery DOM selectors as parameters. But I'm getting errors when I do that-- not sure whether it's my syntax or because Phantom doesn't know about jQuery, so I thought I'd ask first about the PhantomJS/jQuery relationship.
推荐答案
使用page.injectJs('jquery-1.6.1.min.js');它会正常工作.
Use page.injectJs('jquery-1.6.1.min.js'); it will work fine.
here is a beautiful link for using jquery in phantomjs http://snippets.aktagon.com/snippets/534-how-to-scrape-web-pages-with-phantomjs-and-jquery
这篇关于在PhantomJS中使用jQuery DOM选择器语法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!