Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: LWP::Simple setting a proxy

by t0mas (Priest)
on Jan 17, 2001 at 21:13 UTC ( #52549=note: print w/replies, xml ) Need Help??

in reply to LWP::Simple setting a proxy

I usually go:
somewhere before I start getting stuff with it.

But you can also set the environment variable HTTP_proxy in your shell to

/brother t0mas

Replies are listed 'Best First'.
Re: Re: LWP::Simple setting a proxy
by thealienz1 (Pilgrim) on Jan 17, 2001 at 21:20 UTC

    Thanks, but no success... I still get nope. So, maybe I am doing somethign wrong.

    use LWP::Simple; $ENV{HTTP_proxy}=""; #The username that you are looking up print "Please input username: "; $username = <STDIN>; chomp($username); #Gets URL $url = ' +chdesc=' . $username . '&searchfields=H'; print "$url\n"; unless (defined ($page = get($url))) { print "Cannot retrieve page... Sorry =(\n\n"; exit; } #Get Description print "Description: "; if($page =~ m|<A class="desc".*?>(.*?)</A>|) { print "$1\n"; } else{ print "No description\n"; } #Check Profile print "Profile: "; if($page =~ m|<A class="handle".*?>(.*?)</A>|) { print "$1\n"; } else{ print "No profile\n"; } #Connection Speed print "Speed: "; if($page =~ m|<TD ID="connection".*?>(.*?)</TD>|) { print "$1\n"; } else{ print "No connection\n"; } #Number of listeners print "Listeners: "; ($listen,$outof) = (0,0); if($page =~ m|DrawListenerStars("/scp/../images/", (\d+), (\d+))|) {($ +listen,$outof) = ($1,$2);} print "$listen / $outof\n";

    This is supposed to check and return the information of my radio. I know it might see like "Why are you doing this?", but when their web server is so damn slow. It makes it worth not loading their enitre page.

    I am the first overweight, very tall munchkin... be very amazed.
      I bet that LWP::Simple's internal UserAgent gets created at use time, so your env variable definition is not seen.

      Just guessing (untested)... either put your env-var setting inside a BEGIN block before the use:

      BEGIN { $ENV{HTTP_proxy}="" } use LWP::Simple;
      or you can always go "behind the scenes" with LWP::Simple by accessing $LWP::Simple::ua:
      use LWP::Simple qw($ua); $ua->proxy([qw(http ftp)], '');

      -- Randal L. Schwartz, Perl hacker

      I would like to use HTTP::Request::Common and LWP::UserAgent for that kind of stunt and use a POST to submit the data to the server.

      Try out the following:
      #!/usr/bin/perl -w # Uses use strict; use HTTP::Request::Common qw(POST); use LWP::UserAgent; # URL my $url = ''; # User Agent Object my $ua = LWP::UserAgent->new; $ua->proxy(['http', 'ftp'], ''); #The username that you are looking up print "Please input username: "; my $username = <STDIN>; chomp($username); # Request my $req = POST $url, [ genre=>'search', searchdesc=> $username, searchfields=>'H']; my $page=$ua->request($req)->as_string; #The rest of your code goes here

      /brother t0mas

        I needed something fast... I needed something quick... I needed something SIMPLE... hence LWP::Simple!

        I am the first overweight, very tall munchkin... be very amazed.
      Just a guess (since you gave no information on how or what is failing):

      Does your proxy, by any chance, require authentication?

      Have fun ...


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://52549]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2018-05-21 21:13 GMT
Find Nodes?
    Voting Booth?