The site http://openbook.etoro.com/#/main/ has a live channel that is generated by javascript through XHR keep-alive requests and receiving responses from the server as gzip JSON compression.
I want to capture the channel to a file.
The usual way (WWW :: Mech ..) is (probably) unviable because the need to develop reverese of all Javascripts on the page and simulate the browser is really a difficult task, therefore, looking for an alternative solution.
My idea uses Man-in-the-middle tactics, so broswser will do the job, and I want to grab the connection through the perl proxy dedicated to this task only.
I can catch the initial message, but not the channel itself. The proxy works fine, because only my filter works in the browser.
use HTTP::Proxy; use HTTP::Proxy::HeaderFilter::simple; use HTTP::Proxy::BodyFilter::simple; use Data::Dumper; use strict; use warnings; my $proxy = HTTP::Proxy->new( port => 3128, max_clients => 100, max_keep_alive_requests => 100 ); my $hfilter = HTTP::Proxy::HeaderFilter::simple->new( sub { my ( $self, $headers, $message ) = @_; print STDERR "headers", Dumper($headers); } ); my $bfilter = HTTP::Proxy::BodyFilter::simple->new( filter => sub { my ( $self, $dataref, $message, $protocol, $buffer ) = @_; print STDERR "dataref", Dumper($dataref); } ); $proxy->push_filter( response => $hfilter);
Firefox is configured using the above proxy for all posts.
The channel works in the browser, so the proxy server feeds it with data. (When I stop the proxy, the feed also stops). By accident (I can not understand when) I get the following error:
[Tue Jul 10 17:13:58 2012] (42289) ERROR: Getting request failed: Client closed
Can someone show me a way how to construct the correct HTTP :: Proxy filter for Dumper all communication between the browser and server aspects of keep_alive XHR?