OT? want to save web page image automatically

Karl Auer kauer at biplane.com.au
Tue Nov 10 22:21:28 UTC 2020


On Tue, 2020-11-10 at 21:52 +0000, Peter Flynn wrote:
> On 10/11/2020 20:58, Dave Stevens wrote:
> > On Tue, 10 Nov 2020 08:49:56 +0000
> > David Fletcher <dave at thefletchers.net> wrote:
> > 
> > > On Mon, 2020-11-09 at 16:40 -0800, Dave Stevens wrote:
> > > > I have a web page that displays a chart of values that change
> > > > once
> > > > per
> > > > hour. It it uses chart.js under node.js on mint.
> > > > 
> > > > See it here: http://209.145.101.163/24chart.html
> > > > 
> > > > If I right click on the image I have an option (in Firefox) to
> > > > save
> > > > it
> > > > as a png. That works fine. What I'd like to do is save the
> > > > image
> > > > once per hour without intervention. Does anyone know a
> > > > scriptable
> > > > method?
> 
> AFAIK you can run FF from the command line with an option to open a
> page 
> and screenshot it.
> 
> https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode
> 
> Basically, create a special profile first (in about:profiles), and
> then
> 
> $ firefox -P <profilename> --screenshot webpage.jpg https://whatever/
>  --exit
> 
> This creates a (potentially VERY tall, narrow) screenshot of the
> whole 
> page, exactly like Vivaldi's pageshot button does. Excellent for
> making 
> screenshot for documentation.
> 
> Peter
> 

If you want an actual inage or other discrete element off a page, you
can use crl or wget to retrieve it very simply.

In this particular case it's JavaScript output, so not quite so simple,
though you CAN download the JS easily enough, and it onl;ty uses one
external script (Chart) which is also easy to grab.

There would be a little JS programming effort to wrap it up into
something locally executable, and a little more to append one chart to
the previous chart or do some kind of history. Depends whether you are
ever interested in old charts, or only ever want the current one.
Haven't ever used node-red, maybe it could do this - of course this
would mean sliding into addiction followed by inevitable death.

If you really do only want the image (not the liveness of the chart),
then Peter's idea of grabbing a screenshot would be the starting point,
followed by using imagemagick or similar to chop out just the image
(which is at the same position on the page every time).

Or you could write to the author and ask for a static chart below his
live chart, so you can just grab the static image with curl or wget.

Regards, K.

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Karl Auer (kauer at biplane.com.au)
http://www.biplane.com.au/kauer

GPG fingerprint: 2561 E9EC D868 E73C 8AF1 49CF EE50 4B1D CCA1 5170
Old fingerprint: 8D08 9CAA 649A AFEF E862 062A 2E97 42D4 A2A0 616D







More information about the ubuntu-users mailing list