Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8227847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:16:04+00:00 2026-06-07T16:16:04+00:00

The site http://openbook.etoro.com/#/main/ has an live feed what is generated by javascript via XHR

  • 0

The site http://openbook.etoro.com/#/main/ has an live feed what is generated by javascript via XHR keep-alive requests and getting answers from server as gzip compressed JSON string.

I want capture the feed into a file.

The usual way (WWW::Mech..) is (probably) not viable because the need of reverese engineering all Javascripts in the page and simulating the browser is really hard task, so, looking for an alternative solution.

My idea is using a Man-in-the-middle tactics, so the broswser will do his work and i want capture the communication via an perl proxy – dedicated only for this task.

I’m able catch the initial communication, but not the feed itself. The proxy working OK, because in the browser the feed is running only my filers not works.

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); #header dumper
$proxy->push_filter( response => $bfilter); #body dumper
$proxy->start;

Firefox is configured using the above proxy for all communication.

The feed is running in the browser, so the proxy feeding it with data. (When i stop the proxy, the feed is stopping too). Randomly (can’t figure when) i getting the following error:

[Tue Jul 10 17:13:58 2012] (42289) ERROR: Getting request failed: Client closed

Can anybody show me a way, how to construt the correct HTTP::Proxy filter for Dumper all communication between the browser and the server regardles of keep_alive XHR?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:16:05+00:00Added an answer on June 7, 2026 at 4:16 pm

    Here’s something that I think does what you’re after:

    #!/usr/bin/perl
    
    use 5.010;
    use strict;
    use warnings;
    
    use HTTP::Proxy;
    use HTTP::Proxy::BodyFilter::complete;
    use HTTP::Proxy::BodyFilter::simple;
    use JSON::XS     qw( decode_json );
    use Data::Dumper qw( Dumper );
    
    my $proxy = HTTP::Proxy->new(
        port                     => 3128,
        max_clients              => 100,
        max_keep_alive_requests  => 100,
    );
    
    my $filter = HTTP::Proxy::BodyFilter::simple->new(
        sub {
            my ( $self, $dataref, $message, $protocol, $buffer ) = @_;
            return unless $$dataref;
            my $content_type = $message->headers->content_type or return;
            say "\nContent-type: $content_type";
            my $data = decode_json( $$dataref );
            say Dumper( $data );
        }
    );
    
    $proxy->push_filter(
        method   => 'GET',
        mime     => 'application/json',
        response => HTTP::Proxy::BodyFilter::complete->new,
        response => $filter
    );
    
    $proxy->start;
    

    I don’t think you need a separate header filter because you can access any headers you want to look at using $message->headers in the body filter.

    You’ll note that I pushed two filters onto the pipeline. The first one is of type HTTP::Proxy::BodyFilter::complete and its job is to collect up the chunks of response and ensure that the real filter that follows always gets a complete message in $dataref. However foreach chunk that’s received and buffered, the following filter will be called and passed an empty $dataref. My filter ignores these by returning early.

    I also set up the filter pipeline to ignore everything except GET requests that resulted in JSON responses – since these seem to be the most interesting.

    Thanks for asking this question – it was an interesting little problem and you seemed to have done most of the hard work already.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the below site: http://kelseydelo.com/ When I click the main nav links in
Site: http://partsconsign.com/parts/?custid=1 I don't know what happened. All of a sudden, without changing the
On my site: http://alsite.com.br/solalev/ I have some elements on the bottom of page that
When I open my site http://www.gestaoeventos.com on Defy (Android 2.1 update 1 Browser version
Please see this IBM site - http://www.ibm.com/us/en/ If you see the site banners, there
Here is my site: http://smartpeopletalkfast.co.uk/pos/ There is a div #nav which has a fixed
I recently deployed a site http://boardlite.com . One of the tester websites http://www.gidnetwork.com/tools/gzip-test.php suggests
for this site: http://yoursdproperty.com/ do you see how there some extra white space all
Our site http://m.sa2010.gov.za has a simple menu structure that relies on floating divs to
On this site http://www.bostonteaclub.com I want the default language to be Chinese. I set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.