ngoaho91
ngoaho91

Reputation: 133

C++ QtNetworkRequest download image but got HTML

i have this link

http://www.deviantart.com/download/425078223/dota2__wraith_night_by_phsueh-d712wgf.jpg?token=58443eec715f93cd984f8e4f03e287cce3cff717&ts=1390123417

i paste it into my browser then got an image. but when i'm coding to download this, i got some HTML code, here it is:

<html><head><title>Redirection</title></head><body><script type="text/javascript">window.location.href="http:\/\/phsueh.deviantart.com\/art\/DOTA2-Wraith-Night-425078223"</script><noscript><a href="http://phsueh.deviantart.com/art/DOTA2-Wraith-Night-425078223">Click here to continue.</a></noscript></body></html>

can anyone tell me how to get actual image that the link point to.

p/s: i follow this tutorial http://www.java2s.com/Code/Cpp/Qt/DownloadfromURL.htm

Upvotes: 1

Views: 149

Answers (1)

typ1232
typ1232

Reputation: 5587

You need to request the art page first to save the cookie userinfo and get the individual download link (containing token and timestamp) the page gave you. It could be found with a string search for the download button element and extracting the href value.

<a class="dev-page-button dev-page-button-with-text dev-page-download"

Now you just have to send a request for that individual download link with the saved cookie and you will be redirected to your image.

Upvotes: 3

Related Questions