Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is a proxy the right way to do this?

Status
Not open for further replies.

BrianAtWork

Programmer
Apr 12, 2004
148
US
Hi all,
What I am trying to do is be able to browse around on the web and count occurances of certain words while I browse, and keep stats.
I am thinking a proxy would be the best way, but I am having a very hard time - I was using HTTP::proxy but my browser won't connect to my proxy.

Maybe there are web browsers out there that let you program perl addons?

Can anyone think of a good way to do something like this?
 
A proxy sounds like the best idea to me.
Why are you having problems connecting to your proxy?
Can you post some of your code so that we can test it?
Also, can you tell us what OS you are using? It could make a difference.


Trojan.
 
No problem - here's the code just for testing - it doesn't really do anything yet:

Code:
#!c:/perl/bin/Perl.exe
use HTTP::Proxy;
my $proxy = HTTP::Proxy->new();
$proxy->port( 1234 );
{
  package FilterPerl;
  use base qw( HTTP::Proxy::BodyFilter );
  sub filter {
    my ( $self, $dataref, $message, $protocol, $buffer ) = @_;
         $$dataref =~ s/PERL/Perl/g;
    }
  }
  $proxy->push_filter( response => FilterPerl->new() );
  $proxy->start;
This probably looks familiar because I got it from CPAN. This code works on a friend's computer, but when I try this at my computers at home, it doesn't work. I am using Windows XP to browse the web - I have tried running the proxy program on that same box, and point the Web Browser's proxy to local host - I also have a linux box, so I run this proxy on linux and point my Web Browser's proxy to that machine.

It seems like it is "half-way" working, because if this perl program is not running and I try to access a website, I immediately get an error saying the proxy cannot be found. But when the perl program is running and I try to access a website (google.com), the browser sits there forever saying "opening google.com".
I have tried Firefox, Opera, and IE - all give the same problem. I have all of the right perl modules installed on both machines. And I know it isn't the code, because I gave a copy to my friend and it works fine on his computer (Windows XP).

I am behind a router firewall, but this should all be internal, right?

Just really confused...

Thanks!

Brian
 
Is there some reason you're using port 1234 as opposed to port 80?
Firewall's have to pass through port 80 requests but don't necessarily have to pass through requests to some other ports.
I'm not sure that this is your problem but I just thought I'd ask the question.


Trojan.
 
Port 1234 was just the last one I tried. I tried 80, 8080, 1000, and 1234.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top