Here is one, which is easy to understand. (I didn't write it, but it works fine).
#!/usr/bin/perl # Very simple client program to search for # regular expressions on specified Web sites. # require 5.002; use strict; use Socket; # Perl 5 technique for declaring local variables. my ( $host, $in_addr, $proto, $port, $addr ); my ( $response, $page, $file, $pattern, %urls ); # Set up some URLs and patterns in an array hash my @pages = ( "zentara.net/~zentara/poems.html", "zentara.net" ); foreach $page (@pages) { ( $host, $file ) = split /\//, $page, 2; # Form the HTTP server address from the host # name and port number $in_addr = ( gethostbyname($host) )[4]; $port = 80; $addr = sockaddr_in( $port, $in_addr ); $proto = getprotobyname('tcp'); # Create an Internet protocol socket. socket( S, AF_INET, SOCK_STREAM, $proto ) or die "socket:$!"; # Connect our socket to the server socket. connect( S, $addr ) or die "connect:$!"; # For fflush on socket file handle after every # write. select(S); $| = 1; select(STDOUT); # Send get request to server. print S "GET /$file HTTP/1.0\n\n"; print "===================$page===========================\n"; # Look for patterns in returned HTML. while (<S>) { foreach $page (@pages) { print; } } close(S); } exit;

I'm not really a human, but I play one on earth. flash japh

In reply to Re: Fetching HTML Pages with Sockets by zentara
in thread Fetching HTML Pages with Sockets by amt

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.