+ Reply to Thread
Results 1 to 3 of 3

Thread: LWP::Useragent request

  1. #1
    ldsdates is offline x10Hosting Member ldsdates is an unknown quantity at this point
    Join Date
    May 2010
    Posts
    6

    LWP::Useragent request

    Has anyone gotten a useragent request to work? My code shown below allows me to make a web request and puts the response in a variable. It works elsewhere, but when I attempt to use it here it never completes the get($request)

    use LWP::Simple qw($ua get);
    my $ua = new LWP::UserAgent;
    my $request = $_[0];
    $ua->timeout(30);
    $response = get($request);

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: LWP::Useragent request

    That's not quite enough to test. Is the posted fragment part of a function, or is it top-level code? Are you sure $_[0] holds a URL?
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    ldsdates is offline x10Hosting Member ldsdates is an unknown quantity at this point
    Join Date
    May 2010
    Posts
    6

    Re: LWP::Useragent request

    This is the whole thing, wrapped in a sub. - you are right $_[0] is the url you are attempting to get.

    ## Usage: $html=&getpage("http://yourwebsite.com/cgi-bin/page.cgi");
    sub getpage {
    use LWP::Simple qw($ua get);
    my $ua = new LWP::UserAgent;
    my $request = $_[0];
    $ua->timeout(30);
    $response = get($request);
    return "$response";
    }

+ Reply to Thread

Similar Threads

  1. Whats your useragent?
    By Brandon in forum Off Topic
    Replies: 12
    Last Post: 03-19-2006, 03:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers