Use jQuery DOM selector syntax in PhantomJS?

我是研究僧i 提交于 2019-12-12 07:57:48

问题


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:

Sample of PhantomJS with Qunit (and 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.


回答1:


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




回答2:


There is people telling that documentation samples loading JQuery are buggy and load JQuery on PhamtomJS is impossible here: loading jquery on phanthomjs




回答3:


..well, as soon as I posted, I (naturally) found this. Looks like it is possible in fact to include jQuery:

https://github.com/ariya/phantomjs/wiki/Page-Automation



来源:https://stackoverflow.com/questions/14265604/use-jquery-dom-selector-syntax-in-phantomjs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!