Hi...
Here''s a working Perl script that I want to be able to do in Ruby:
use WWW::Mechanize;
my $url = "http://host/tt?name=chris";
my $mech = WWW::Mechanize->new();
$mech->add_header( Referer =>
"http://chrismcmahonsblog.blogspot.com" );
$mech->add_header( Cookie => "messageid=170118; memberid=1007");
$mech->get($url)
so the header values for Referer and Cookie are passed with the HTTP GET.
There seems to be an add_field method in mechanize.rb:
request.add_field(''Referer'', cur_page.uri.to_s)
and rdoc (http://mechanize.rubyforge.org/) indicates an add_field value for
Net::HTTPHeader, but the example is funny, because the example says
"add_header", not "add_field".
In either case, none of the "add_*" statements in the script below
work,
each yields an "undefined method" error.
require ''mechanize''
mech = WWW::Mechanize.new
#request.add_header(''Referer'',
"http://chrismcmahonsblog.blogspot.com" )
#mech.add_header(''Referer'',
"http://chrismcmahonsblog.blogspot.com" )
#mech.add_field(''Cookie'', "messageid=170118;
memberid=1007")
puts mech.get("http://host/tt?name=chris").inspect
can anyone tell me how to add Referer and Cookie headers to an HTTP GET
request?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/mechanize-users/attachments/20061209/aa4e35d2/attachment.html
Hi...
Here''s a working Perl script that I want to be able to do in Ruby:
use WWW::Mechanize;
my $url = "http://host/tt?name=chris";
my $mech = WWW::Mechanize->new();
$mech->add_header( Referer =>
"http://chrismcmahonsblog.blogspot.com" );
$mech->add_header( Cookie => "messageid=170118; memberid=1007");
$mech->get($url)
so the header values for Referer and Cookie are passed with the HTTP GET.
There seems to be an add_field method in mechanize.rb:
request.add_field(''Referer'', cur_page.uri.to_s)
and rdoc (http://mechanize.rubyforge.org/) indicates an add_field value for
Net::HTTPHeader, but the example is funny, because the example says
"add_header", not "add_field".
In either case, none of the "add_*" statements in the script below
work,
each yields an "undefined method" error.
require ''mechanize''
mech = WWW::Mechanize.new
#request.add_header(''Referer'', "
http://chrismcmahonsblog.blogspot.com" )
#mech.add_header(''Referer'',
"http://chrismcmahonsblog.blogspot.com " )
#mech.add_field(''Cookie'', "messageid=170118;
memberid=1007")
puts mech.get("http://host/tt?name=chris").inspect
can anyone tell me how to add Referer and Cookie headers to an HTTP GET
request?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/mechanize-users/attachments/20061209/f3cee23b/attachment.html