Help getting into HTML file.

J

Jim Simpson

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
 
G

Gunnar Hjalmarsson

Jim said:
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. :)
 
P

Paul Lalli

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
 
J

John Bokma

Jim said:
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
 
K

Ken Sington

Jim said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top