Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

http get request help

by heywait86 (Initiate)
on Apr 29, 2010 at 02:27 UTC ( [id://837430]=perlquestion: print w/replies, xml ) Need Help??

heywait86 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I don't know if this is even possible, but I'm trying to do a html get request with perl. I've tried using several modules, but have had no success, my current code looks like this, I'm sure I'm doing it all wrong but this is what I have based on googling.
#!/usr/bin/perl use Net::Telnet (); $server = "xxxx.xxxxxxx.xxx"; $cmd = "GET / HTTP/1.1\n\n"; $t = new Net::Telnet ("Timeout" => 10, "Port" => 81 "Prompt" => ''); $t->open($server); @lines = $t->cmd($cmd); print @lines;

Replies are listed 'Best First'.
Re: http get request help
by merlyn (Sage) on Apr 29, 2010 at 02:48 UTC
    use LWP::Simple; my $result = get "http://www.perlmonks.org";

    -- Randal L. Schwartz, Perl hacker

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Re: http get request help
by pemungkah (Priest) on Apr 29, 2010 at 02:51 UTC
    Yep, you're doing it all wrong. You really, really want to be using LWP or WWW::Mechanize. Either of those should Just Work for you.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://837430]
Approved by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-19 05:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found