Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var rawHTML = '<html>'
- + '<head>'
- + '</head>'
- + '<body>'
- + '<script>'
- + 'var connect = function() {'
- + 'var client = new WebSocket("ws://localhost:11131");'
- + 'client.onmessage = function(msg) {'
- + 'var data = JSON.parse(msg.data);'
- // (1) do your parsing here by loading the URL in an iframe
- // once you are done, just send the result back via websocket.
- // (2) for the downloads, you can again send the cookies from the iframe
- // via postMessage API via websockets to your app.
- // (3) injecting variables into browser session should be a piece of cake
- // with this method. you just need to eval the stuff you have sent
- // via websockets.
- // (4) link traversing can be achieved by using the postMessage API again.
- + 'client.send(JSON.stringify({'
- + 'data: data'
- + '}));'
- + '};'
- + 'client.onclose = function(msg) {'
- + 'console.log("Phantom Socket Closed! Reconnecting...");'
- + 'connect();'
- + '};'
- + '};'
- + 'connect();'
- + '</script>'
- + '</body>'
- + '</html>';
- var page = require('webpage').create();
- page.localToRemoteUrlAccessEnabled = true;
- page.content = rawHTML;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement