Help getting into HTML file.

Discussion in 'Perl Misc' started by Jim Simpson, Jun 25, 2004.

  1. Jim Simpson

    Jim Simpson Guest

    I have the following line of code:

    <my $response = $ua->post(whatever)>

    The $response which is returned contains HTML code and is now printing on
    the DOS screen. How can I get it into an .html file so I can see it on my
    computer screen?

    Thanks,

    Jim
    Jim Simpson, Jun 25, 2004
    #1
    1. Advertising

  2. Jim Simpson wrote:
    > I have the following line of code:
    >
    > <my $response = $ua->post(whatever)>
    >
    > The $response which is returned contains HTML code and is now
    > printing on the DOS screen. How can I get it into an .html file so
    > I can see it on my computer screen?


    open my $fh, '> myfile.html' or die $!;
    print $fh $response -> content;
    close $fh;

    (untested)

    Then view it with your browser. :)

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Jun 25, 2004
    #2
    1. Advertising

  3. Jim Simpson

    Paul Lalli Guest

    On Fri, 25 Jun 2004, Jim Simpson wrote:

    > I have the following line of code:
    >
    > <my $response = $ua->post(whatever)>
    >
    > The $response which is returned contains HTML code and is now printing on
    > the DOS screen. How can I get it into an .html file so I can see it on my
    > computer screen?


    What are you asking? Do you want to print the response to your browser?
    Do you want to save the result to a new HTML file on your local computer?

    I'm going to assume the latter for now. Somewhere along the way, you must
    be printing the response. Rather than printing it to standard output (the
    default), open a new file for writing, and print to that file instead.

    For documentation on how to do this, see:
    perldoc -f open
    and
    perldoc -f print

    After reading that documentation and making an attempt, if you still have
    problems, let us know.

    Paul Lalli
    Paul Lalli, Jun 25, 2004
    #3
  4. Jim Simpson

    John Bokma Guest

    Jim Simpson wrote:

    > I have the following line of code:
    >
    > <my $response = $ua->post(whatever)>
    >
    > The $response which is returned contains HTML code and is now printing on
    > the DOS screen. How can I get it into an .html file so I can see it on my
    > computer screen?



    "$ua->get( $url , $field_name => $value, ... )
    This method will dispatch a GET request on the given $url. Further
    arguments can be given to initialize the headers of the request. These
    are given as separate name/value pairs. The return value is a response
    object. See the HTTP::Response manpage for a description of the
    interface it provides.

    Fields names that start with ``:'' are special. These will not
    initialize headers of the request but will determine how the response
    content is treated. The following special field names are recognized:

    :content_file => $filename
    :content_cb => \&callback
    :read_size_hint => $bytes

    If a $filename is provided with the :content_file option, then the
    response content will be saved here instead of in the response object. "

    "... post... Additional headers and content options are the same as for
    the get() method. "

    RTFM

    --
    John MexIT: http://johnbokma.com/mexit/
    personal page: http://johnbokma.com/
    Experienced Perl programmer available: http://castleamber.com/
    Happy Customers: http://castleamber.com/testimonials.html
    John Bokma, Jun 25, 2004
    #4
  5. Jim Simpson

    Ken Sington Guest

    Jim Simpson wrote:

    > I have the following line of code:
    >
    > <my $response = $ua->post(whatever)>
    >
    > The $response which is returned contains HTML code and is now printing on
    > the DOS screen. How can I get it into an .html file so I can see it on my
    > computer screen?
    >
    > Thanks,
    >
    > Jim
    >
    >

    perhaps:
    perl myprog.pl > mypage.html
    in DOS command prompt.
    and opening it in your browser.
    that may be simpler
    Ken Sington, Jun 26, 2004
    #5
  6. Jim Simpson

    Jim Simpson Guest

    Thanks to all who responded - very helpful.

    Jim


    "Ken Sington" <ken_sington@nospam_abcdefg.com> wrote in message
    news:...
    > Jim Simpson wrote:
    >
    > > I have the following line of code:
    > >
    > > <my $response = $ua->post(whatever)>
    > >
    > > The $response which is returned contains HTML code and is now printing

    on
    > > the DOS screen. How can I get it into an .html file so I can see it on

    my
    > > computer screen?
    > >
    > > Thanks,
    > >
    > > Jim
    > >
    > >

    > perhaps:
    > perl myprog.pl > mypage.html
    > in DOS command prompt.
    > and opening it in your browser.
    > that may be simpler
    Jim Simpson, Jun 26, 2004
    #6
    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. Replies:
    3
    Views:
    12,163
    Beauregard T. Shagnasty
    Jan 10, 2006
  2. John Dalberg
    Replies:
    2
    Views:
    11,683
    Spartanicus
    Aug 20, 2006
  3. Kevin
    Replies:
    1
    Views:
    543
    dorayme
    Apr 15, 2007
  4. Jozza
    Replies:
    1
    Views:
    1,842
    Jozza
    Mar 4, 2010
  5. Patrick Rutledge
    Replies:
    7
    Views:
    401
    Roedy Green
    Jan 31, 2013
Loading...

Share This Page