Community discussions

MikroTik App
 
jeremyh
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 66
Joined: Tue Jul 10, 2012 1:21 pm

Using wget to retrieve Dude network maps (.png)

Wed May 14, 2014 9:00 am

Hi

I would like to retrieve some network map images from The Dude via http so that I can place them in a rotating slideshow thing we use that displays dashboards of other information.
To do this it is necessary for me to save the generated image in a directory in my webserver (and overwrite the file each time it is retrieved and saved), ie:
wget http://{Dude-IP}:8080/dude/Global.png?page=map_picture&download=yes&id=2897221 -O netmap.png
However, The Dude requires that a javascript form be submitted before the image is accessible (if I try to request the image file now, it downloads a HTML file asking for login details) and/or, I guess, a cookie for the session.

I know that wget is able to submit POST requests and can probably do this, but it is a bit beyond my abilities.
Has anyone tried this and is able to share their method?

Thanks!
 
Shkrid
just joined
Posts: 17
Joined: Wed Mar 13, 2013 11:06 am

Re: Using wget to retrieve Dude network maps (.png)

Wed May 14, 2014 9:52 am

Hi

I would like to retrieve some network map images from The Dude via http so that I can place them in a rotating slideshow thing we use that displays dashboards of other information.
To do this it is necessary for me to save the generated image in a directory in my webserver (and overwrite the file each time it is retrieved and saved), ie:
wget http://{Dude-IP}:8080/dude/Global.png?page=map_picture&download=yes&id=2897221 -O netmap.png
However, The Dude requires that a javascript form be submitted before the image is accessible (if I try to request the image file now, it downloads a HTML file asking for login details) and/or, I guess, a cookie for the session.

I know that wget is able to submit POST requests and can probably do this, but it is a bit beyond my abilities.
Has anyone tried this and is able to share their method?

Thanks!
Maybe this example helps you:
wget --cookies=on --keep-session-cookies --save-cookies=$workdir/cookie.txt --progress=dot:mega "http://$server:$serverport/dude/main.html?process=login&user=$user&password=$password" -O $workdir/page1.html 2>> $logfile
wget --cookies=on --load-cookies=$workdir/cookie.txt --progress=dot:mega "http://$server:$serverport/dude/$serverfilename?page=savefile&download=yes" -O $backupdir/$backupname 2>> $logfile
 
jeremyh
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 66
Joined: Tue Jul 10, 2012 1:21 pm

Re: Using wget to retrieve Dude network maps (.png)

Wed May 14, 2014 10:09 am

Hi Shkrid,

This is interesting, have you tried this yourself?

I couldn't get it to work. It seems that the process to authenticate to a html form and submit it to a particular URL is more difficult than just the standard http authentication prompt.

Thanks,
Jeremy
 
Shkrid
just joined
Posts: 17
Joined: Wed Mar 13, 2013 11:06 am

Re: Using wget to retrieve Dude network maps (.png)

Wed May 14, 2014 1:47 pm

Hi Shkrid,

This is interesting, have you tried this yourself?

I couldn't get it to work. It seems that the process to authenticate to a html form and submit it to a particular URL is more difficult than just the standard http authentication prompt.

Thanks,
Jeremy
All works fine...
shkrid@workpc:~/dude$ wget --cookies=on --keep-session-cookies --save-cookies=cookie.txt --progress=dot:mega "http://xxx.xxx.xxx.xxx/dude/main.html?process=login&user=LOGIN_NAME&password=PASSWORD" -O page1.html
--2014-05-14 13:34:51--  http://xxx.xxx.xxx.xxx/dude/main.html?process=login&user=LOGIN_NAME&password=PASSWORD
Connecting to xxx.xxx.xxx.xxx:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5384 (5,3K) [text/html]
Saving to: `page1.html'. 

     0K                                                      100% 10,1M=0,001s

2014-05-14 13:34:51 (10,1 MB/s) - `page1.html' saved [5384/5384]

shkrid@workpc:~/dude$ wget --cookies=on --load-cookies=cookie.txt --progress=dot:mega "http://xxx.xxx.xxx.xxx/dude/MAP_NAME.png?page=map_picture&download=yes&id=95199592" -O test.png
--2014-05-14 13:34:58--  http://xxx.xxx.xxx.xxx/dude/MAP_NAME.png?page=map_picture&download=yes&id=95199592
Connecting to xxx.xxx.xxx.xxx:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 131873 (129K) [image/png]
Saving to: `test.png'.

     0K ..                                                   100% 7,90M=0,02s

2014-05-14 13:34:58 (7,90 MB/s) - `test.png' saved [131873/131873]

shkrid@workpc:~/dude$ head test.png 
�PNG

IHDR�ɑ�)s��O� I
....
....

shkrid@workpc:~/dude$ 

Who is online

Users browsing this forum: No registered users and 22 guests