Is it possible to download files from from file hosting sites using QNetworkAccessManager
-
I tried my level best to download a file from uploading.com but all in vain. I tried every possible way of redirection, but all in vain. It always ends up with error Moved Permanently and if you try redirections it ends up downloading the web page.
-
You've already addressed this issue in a couple of other threads. Please continue the discussion there, rather than opening another thread.
-
Actually, that thread discusses an issue related to cookies. But this time it is not related to cookies. I tried downloading without a premium account using regular download option and it failed every time. On the other hand, the inbuilt download manager of firefox doesn't seem to have any problem.
-
bq. Is it possible to download files from from file hosting sites using QNetworkAccessManager
Yes. You'll probably need to ensure you obtain and keep relevant cookies, follow a similar path to that a human would take, follow redirections etc.
-
Actually, the problem is with non-premium accounts. They only allow one download at a time. When we try to download using QNetworkAccessManager, it makes a get request on the url, which was already used by firefox, file hosting sites disallow this and redirect all further requests to their webpage. So, redirection causes the page to be downloaded instead of file. Obviously, this problem is with non-premium accounts only.
Besides, is there any advantage of using redirection feature of QNetworkAccessManager to fetch the new url over using the following method:
@if(statusCode==307||dSegment[0].replySegment->rawHeaderList().contains("Location"))
{
downUrl=reply->header(QNetworkRequest::LocationHeader).toString();
} @ -
Does their website use JavaScript redirection? If I'm not mistaken, QNetworkAccessManager can't handle those.
-
What redirection mechanism in QNetworkAccessManager? The QNetworkReply it gives you represents what the server sends. Neither class follows redirections or sends a new request.
Web browsers follow redirections and execute Javascript by default, which is why Firefox works.
I fail to see what all the other talk bemoaning the service's anti-leaching/revenue protection measures has to do with Qt.
-
I meant difference between theses two
@redirect = reply.attribute(QNetworkRequest.RedirectionTargetAttribute).toUrl()@@downUrl=reply->header(QNetworkRequest::LocationHeader).toString(); @