QHttp download file problem.
#include <QApplication>
#include <QHttp>
#include <QUrl>
#include <QFileInfo>
#include <QFile>
#include <QtDebug>
class QHttp;
int main(int argc,char *argv[])
{
QApplication qapp(argc,argv);
QHttp *http;
http=new QHttp();
QUrl *url=new QUrl("http://feymercurial.com/forum/profile.php?mode=viewprofile&u=873");
QFileInfo fileinfo(url->path());
QFile *file = new QFile(fileinfo.fileName());
file->open(QIODevice::WriteOnly);
http->setHost(url->host(),80);
int httpGetId=http->get(url->path(),file);
qDebug() << httpGetId;
return qapp.exec();
}
--------------------------------
:confused:
QUrl *url=new QUrl("http://feymercurial.com/forum/profile.php?mode=viewprofile&u=873");
file profile.php is empty.
but if : QUrl *url=new QUrl("http://www.a2gold.com/index_en.php");
the file index_en.php is have content.
why?
Re: QHttp download file problem.
Are you implementing some spam related software?
Re: QHttp download file problem.
NO NO~ haha~
:) my Boss will salesmanship some our product, so let me find MSN number~
our product is about game WOW.
I think this not spam related software :)
Re: QHttp download file problem.
Re: QHttp download file problem.
Start by moving that QUrl object to stack.Then connect to QHttp signals that transmit information about the response header and display the header contents, it'll probably tell you something important (at least the status code).
Re: QHttp download file problem.
QHttp download file problem.
My case:
page with parameter can download:http://www.a2gold.com/index_en.php
page without parameter,can't download:http://feymercurial.com/forum/profil...wprofile&u=873
Code:
Code:
int main(int argc,char *argv[])
{
//QUrl *url=new QUrl("http://feymercurial.com/forum/profile.php?mode=viewprofile&u=873"); [COLOR="red"] //this can't download. [/COLOR]
QUrl *url
=new QUrl("http://www.a2gold.com/index_en.php");
[COLOR
="Red"] //this can download. [/COLOR]
http->setHost(url->host(),80);
int httpGetId=http->get(url->path(),file);
qDebug() << httpGetId;
return qapp.exec();
}
how can i download a page with a parameter?
Re: QHttp download file problem.
Simply dont use path(), instead use text parsing, here is an example:
Code:
bool HttpGetFile::ParseUrl( const QString& qstrUrlIn, int& iError )
{
if( qstrUrlIn.length() == (qUrl.scheme().length() + 3 + qUrl.host().length()) )
{
qstrUrl += "/";
qUrl = qstrUrl;
}
if( !qUrl.isValid() )
{
iError = 8;
return false;
}
if( qUrl.scheme() != "http" )
{
iError = 9;
return false;
}
qstrHost = qUrl.host();
qstrPath = qstrUrl.remove( 0, 7 + qstrHost.length() );// 7 == http://
return true;
}
Re: QHttp download file problem.
Re: QHttp download file problem.
Quote:
Originally Posted by
fengtian.we
:) my Boss will salesmanship some our product, so let me find MSN number
What do you intend to do with those numbers? Because if you want to send them a message "hey, buy our great software", then that's spamming.
Re: QHttp download file problem.
Please, don't start more than one thread on the same problem. Threads merged.
Re: QHttp download file problem.
my boss sell the WOW(online game) gold :)
Re: QHttp download file problem.
This doesn't answer my question.