HTML2JPEG

K

katja

How can I convert an Internet-page to a PDF/JPEG-file from a
Perl-script under Linux? (I would like to make a screenshot from a
command line).
Thank you
Katja
 
R

Roman M. Parparov

katja said:
How can I convert an Internet-page to a PDF/JPEG-file from a
Perl-script under Linux? (I would like to make a screenshot from a
command line).
Thank you
Katja

Since every browser for every platform for every user renders the WWW
pages differently, it is unclear whether your task is well-defined, thus
an answer should not be possible. You can download the contents of a web
page as a text file easily. Converting text files on Linux is often
done using wv suite (wvText, wvPDF et al.) which operates installed
converting programs like latex, distill and others through a shell script
wrapper.
 
K

Katja Zinchenko

*** Roman M. Parparov, 07-Dec-04, 14:06 h ***
Since every browser for every platform for every user renders the WWW
pages differently, it is unclear whether your task is well-defined, thus
an answer should not be possible. You can download the contents of a web
page as a text file easily. Converting text files on Linux is often
done using wv suite (wvText, wvPDF et al.) which operates installed
converting programs like latex, distill and others through a shell script
wrapper.

Thanks for the hint, and sorry, yes, my question was too vague. What I wanted to
ask is: Is there a perlish way to save the contents of a web page to an image
file exactly the way a browser (any recent browser) would render it? I'd like to
pass my script a url and automatically get a kind of screen shot of the web
page. There doesn't seem to be a perl module (at least not on CPAN) to that
purpose, and as far as I could find out, mozilla, firefox, galeon, konqueror and
opera don't support any command line options to have them print to a file.

Thank you,
Katja
 
R

Roman M. Parparov

Katja Zinchenko said:
Thanks for the hint, and sorry, yes, my question was too vague. What I wanted to
ask is: Is there a perlish way to save the contents of a web page to an image
file exactly the way a browser (any recent browser) would render it? I'd like to
pass my script a url and automatically get a kind of screen shot of the web
page. There doesn't seem to be a perl module (at least not on CPAN) to that
purpose, and as far as I could find out, mozilla, firefox, galeon, konqueror and
opera don't support any command line options to have them print to a file.
Thank you,
Katja

But even the same browser would show it differently for various users.
You must also realize that most of the sites do not fit within one browser
window which is about 1024x768 pixels in size.

The only way that comes to mind - an abstract implementation:
1) Launch the browser to the requested URL from a perl script.
Your browser and whatever it displays are an X11 window within your
window manager/desktop environment.

2) Use the perl library corresponding to your window manager or even an
X11 perl interface to capture the window into an image.

OR

2) Use scriptlets supplied with your window manager (some have them) that
do the window capture. AFAIK Afterstep has this ability. I am not sure
but it is possible that X11 package has a program to take a shot of a full
desktop. Then, knowing your browser X11 geometry you can crop out the
browser itself.

The image would usually be saved in the XWD format.

3) Use an image conversion library of perl (or an external application)
to convert XWD to JPG or whatever.

Note: all this might be done with a shell script and existing Linux
utilities without Perl.
 
J

Jürgen Exner

Katja said:
Thanks for the hint, and sorry, yes, my question was too vague. What
I wanted to ask is: Is there a perlish way to save the contents of a
web page to an image file exactly the way a browser (any recent
browser) would render it?

Of course. And it is so trivial that you don't even need Perl.
Just use Lynx. It has an option to write the rendered text to a file:

-dump
dumps the formatted output of the default document or one specified on the
command line to standard out.

Further details see
http://lynx.isc.org/current/lynx2-8-5/lynx_help/Lynx_users_guide.html

jue
 
R

Roman M. Parparov

Of course. And it is so trivial that you don't even need Perl.
Just use Lynx. It has an option to write the rendered text to a file:
-dump
dumps the formatted output of the default document or one specified on the
command line to standard out.

I suspect Katja wants to take screenshots of specific pages _including_
graphics, so lynx isn't sufficient.
 
J

Jürgen Exner

Roman said:
I suspect Katja wants to take screenshots of specific pages
_including_ graphics, so lynx isn't sufficient.

<quote>
the way [...] any recent browser would render it
</quote>

Anything beyond that is pure speculation

jue
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top