sheebz / phantom-proxy

a lightweight proxy that lets you to drive phantomjs from node.
MIT License
137 stars 34 forks source link

Error when calling page.evaluate with a function, which contains regexp #51

Open capaj opened 11 years ago

capaj commented 11 years ago

Whenever I call page.evaluate with any of these two types of defining regex:

var patt1=new RegExp("\r\n|\r|\n");
var splitted = h1.innerText.split(patt1);

or

var splitted = h1.innerText.split(/\r\n|\r|\n/);

I get this error:

events.js:73 throw new Error("Uncaught, unspecified 'error' event."); ^ Error: Uncaught, unspecified 'error' event. at EventEmitter.emit (events.js:73:15) at parseResponse (D:\Github\psp.cz-scraper\node_modules\phantom-proxy\lib\proxy.js:124:50) at Socket.self.proxy.page (D:\Github\psp.cz-scraper\node_modules\phantom-proxy\lib\proxy.js:203:21) at Socket.EventEmitter.emit as $emit at SocketNamespace.handlePacket (D:\Github\psp.cz-scraper\node_modules\phantom-proxy\node_modules\socket.io\lib\namespace.js:335:22) at Manager.onClientMessage (D:\Github\psp.cz-scraper\node_modules\phantom-proxy\node_modules\socket.io\lib\manager.js:488:38) at WebSocket.Transport.onMessage (D:\Github\psp.cz-scraper\node_modules\phantom-proxy\node_modules\socket.io\lib\transport.js:387:20) at Parser. (D:\Github\psp.cz-scraper\node_modules\phantom-proxy\node_modules\socket.io\lib\transports\websocket\default.js:36:10) at Parser.EventEmitter.emit (events.js:96:17) at Parser.parse (D:\Github\psp.cz-scraper\node_modules\phantom-proxy\node_modules\socket.io\lib\transports\websocket\default.js:343:12)

Process finished with exit code 1

I run on phantom-proxy 0.1.792, node.js 0.8.20 and win8 64-bit. Is this issue solvable? If not, it would be nice to mention it in the docs for page.evaluate, because it can really take some time to figure out that the regex is the issue. Thanks in advance.

GCheung55 commented 11 years ago

++