在PhantomJS中使用jQuery DOM选择器语法? [英] Use jQuery DOM selector syntax in PhantomJS?

查看:312
本文介绍了在PhantomJS中使用jQuery DOM选择器语法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习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:

带有Qunit(和jQuery?)的PhantomJS示例

如果您在顶部查看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.

这是在phantomjs中使用jquery的漂亮链接

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆