in reply to Faking referer with LWP::UserAgent

Typos aside ($reg), that does look like it sets the referring URL correctly.

Perhaps the site requires that you obtain a cookie by visiting the referring URL's page ?

Also, I don't see where you're actually getting the page. (ie: calling $ua->get)

-David

Replies are listed 'Best First'.
Re^2: Faking referer with LWP::UserAgent
by Anonymous Monk on Oct 06, 2007 at 03:51 UTC
    I'm confused and have this now. Am I closer to getting it right? Not it says it cannot find header via package UserAgent
    #!/usr/bin/perl use warnings; use strict; use CGI qw/:standard/; use LWP::UserAgent; use CGI::Carp qw/fatalsToBrowser/; print header, start_html(); my $ua = LWP::UserAgent->new; $ua->agent("google.com"); $ua->header('Referer', 'http://www.google.com'); $ua->agent('testing'); $ua->get('http://dragcave.ath.cx/viewdragon/Vjwf'); print $ua->content;
      Something like this should work:

      use LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->agent("google.com"); my $response = $ua->get('http://dragcave.ath.cx/viewdragon/Vjwf', Refe +rer => 'http://www.google.com'); print $response->content;
      However, I really doubt thats the kind of security they'd be using. Usually, the referring URL would be a URL on their own site. If they discriminate at all, it'll be purely on user-agent string.

      -David

      my $ua = LWP::UserAgent->new(); $ua->agent("google.com"); my $req = HTTP::Request->new(GET => $uri); $req->header('Referer', 'http://www.google.com'); $ua->request($req);