Storing downloaded webpages into files

Discussion in 'Perl Misc' started by PuZzLeD, May 19, 2004.

  1. PuZzLeD

    PuZzLeD Guest

    Hi,
    I have a problem here. I am supposed to be saving downloaded web pages
    on to a a local cache. I have written a forking proxy server that
    reads the request frm the browser and passes the request to the
    Internet Gateway and then gets back the data from the internet gateway
    and then passes it on to the browser. I need to save the files that
    are associated with each request into a local cache. I have attached
    the server code below...


    server_listenport = IO::Socket::INET->new(
    LocalPort => $server_listenport,
    Listen => $listen_queuesize)
    or die "couldnt be a tcp server on port $server_listenport:
    $@\n";


    while($browser_request=$server_listenport->accept())
    {
    if (fork == 0)
    {
    #child
    print " \n\nUsing Child Proceess...\n";
    close ($server_listenport);
    sysread($browser_request,$req_webpage,2048);
    $date_stamp= `date`;
    $internet_gateway =IO::Socket::INET->new(
    PeerPort=>$IGway_listenport,
    PeerAddr=>$IGway_hostname) or die " cannot
    connect to gateway";

    syswrite($internet_gateway,$req_webpage);

    while(sysread($internet_gateway, $recv_webpage, 20480) > 0)
    {
    syswrite($browser_request,$recv_webpage);
    }
    print "\n\n\tWeb page is now downloaded!!\n\n";
    close($internet_gateway);

    exit;
    }
    }
    else
    {
    #parent
    print " \n\nUsing Parent Process...\n";
    close($browser_request);
    }
    } #end of while


    Can some1 help me ?
     
    PuZzLeD, May 19, 2004
    #1
    1. Advertising

  2. PuZzLeD

    Ben Morrow Guest

    Quoth (PuZzLeD):
    > Hi,
    > I have a problem here. I am supposed to be saving downloaded web pages
    > on to a a local cache. I have written a forking proxy server that
    > reads the request frm the browser and passes the request to the
    > Internet Gateway and then gets back the data from the internet gateway
    > and then passes it on to the browser. I need to save the files that
    > are associated with each request into a local cache. I have attached
    > the server code below...


    What is your problem? You don't know how to save the data?

    You should rewrite this using HTTP::Daemon and LWP, or indeed
    HTTP::proxy.

    Ben

    --
    The cosmos, at best, is like a rubbish heap scattered at random.
    - Heraclitus
     
    Ben Morrow, May 19, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul J. Lay
    Replies:
    2
    Views:
    656
    Steven Cheng[MSFT]
    Apr 8, 2004
  2. ree
    Replies:
    1
    Views:
    740
    Thomas Matthews
    Nov 19, 2003
  3. Ray Slakinski
    Replies:
    0
    Views:
    302
    Ray Slakinski
    May 10, 2005
  4. Jonathan Wood
    Replies:
    1
    Views:
    530
    Jonathan Wood
    Jun 2, 2008
  5. Wolfgang Nádasi-Donner
    Replies:
    7
    Views:
    149
    Wolfgang Nádasi-Donner
    Jul 28, 2005
Loading...

Share This Page