开发者

http client that executes javascript...?

Does anyone know of an http client that is scripting friendly (ie: the basics, gets, posts) and is capable开发者_Go百科 of executing javascript (all, not just location redirect) ? And one which isn't just launching another browser.


There are now tools to achieve exactly what you are asking. The best class of tool, if not the only one, is probably the "headless-browser".

There have apparently been a few attempts at headless browsers, but the one that seems to have got it right is called PhantomJS.

PhantomJS is basically a WebKit browser without any display, so all the layout logic, JavaScript, etc is all in there along with the basic HTTP client, just like in a browser - because it is a browser.

PhantomJS exposes some kind of interface in JavaScript but apparently it's not so easy to use on its own. Another project has popped up to make it more useful, CasperJS.

One more project deserves mention here, SpookyJS. It's job is to act as a middleman between node.js and PhantomJS, since both implement a JavaScript event loop it's not easy to integrate them. With SpookyJS you can script a HTTP client in JavaScript on your desktop or server.


As far as I know there is no such thing available (although I'm keeping an eye on this thread hoping to be proved wrong).

However if your prepared to roll up your sleeves and do some work, then it should be possible to implement sucah a thing based on Firefox with a xul script - or you might consider looking at, for example, rhino - which is a javascript engine without a browser.

Elinks is a text-mode browser with javascript - so it would probably be simpler to run that in a pty compared with implementing your own browser component and exposing the DOM to rhino.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜