0

I want to make a script to download the image at best resolution (not the preview image) from a deviantART link, as if I clicked the "Download" button.

However, it seems that deviantART redirect the browser to download the image from another source, and I can't find how to get this source via the bash script.

For example, I want to give this link as input:

http://earthsong9405.deviantart.com/art/The-Big-Boys-357700214

And get the image located here:

http://fc05.deviantart.net/fs71/f/2013/077/1/c/the_big_boys_by_earthsong9405-d5wyr92.png

Via the address given by the link in the download button:

_http://www.deviantart.com/download/357700214/the_big_boys_by_earthsong9405-d5wyr92.png?token=add3c3dbf4112b7140930c574a819878509c7ebc&ts=1403209394

1 Answer 1

0

Till the code of the page will be of this type you can do it with a little script as the one below:

MyUrl=$1

File_Url=$(wget -q -O - "$MyUrl")    # here you put the file html in a variable 
Line=$(echo "$File_Url" |grep -e 'meta name="og:image"')   # select only 1 line
# echo $Line
Img=$(echo $Line |sed -e 's/<meta name="og:image" content="//g' -e 's/">//g')
# echo $File_To_Download
wget -q  $Img

The url of the image you are searching for is included in a tag meta name="og:image"
So you can download with wget the page, pass through grep to select a unique line, clean of what is not needed with sed.
Once you obtain in this way the url of your image (in the script in inside the variable Img), you can use again wget to download it.

This is valid till the internal code of the page will be of this type. Else you have to find another way to select the unique tag that is interesting for you.

You must log in to answer this question.