1

我需要一个函数来从“会议结果”中下载 csv 文件: http ://www.rwwa.com.au/cris/meetingdownload.aspx?meeting=15014

问题是您需要单击“会议结果”链接才能获取文件。

此链接具有以下关联 URL:javascript:__doPostBack('ctl00$ContentPlaceHolderMain$linkBut​​tonResults','')

如何在 Qt 中模拟点击下载文件?

注意:我检查了 Qt 中的 HTTP 示例,但由于 csv 文件没有直接链接,我不知道如何下载它。

谢谢大家的时间和答案。此致

4

1 回答 1

0

也就是说,使用 WireShark 得到的 HTTP 是(Qt 代码如下):

POST /cris/meetingdownload.aspx?meeting=15016 HTTP/1.1
Host: www.rwwa.com.au
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.16) Gecko/20110323 Ubuntu/10.10 (maverick) Firefox/3.6.16
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://www.rwwa.com.au/cris/meetingdownload.aspx?meeting=15016
Cookie: __utma=125158281.121279034.1302968401.1303017966.1303024785.5; __utmz=125158281.1302968401.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none); rwwa_home=SID-4E7CCEFA-2D53D8FE; JSESSIONID=C7C7911A58DF8F12AAF4B426BD347520; __utmc=125158281
Content-Type: application/x-www-form-urlencoded
Content-Length: 557

__EVENTTARGET=ctl00%24ContentPlaceHolderMain%24linkButtonResults&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUKLTI3Njg4NTg5OA9kFgJmD2QWBAIDDxYCHgRUZXh0BSUNCjwhLS1XUzogVlRBQjIzMEM7IEFTOiBWVEFCMjIwQy0tPg0KZAIFD2QWAgIBD2QWDAIBDw8WAh8ABR5DUklTOiBNZWV0aW5nIERvd25sb2FkIE9wdGlvbnNkZAIDD2QWAmYPFgIeB1Zpc2libGVoZAIFDw8WAh8ABSVQSU5KQVJSQSBSQUNFIENMVUIsIFN1bmRheSAxNy8wNC8yMDExZGQCBw8PFgIfAAUSKGF0IFBJTkpBUlJBIFBBUkspZGQCCQ8WAh8BaGQCDQ8WAh8BaBYCAgMPFgIfAWhkZFF%2Fdlkb2PzfgrCf7N5ngJjqeu9J&__EVENTVALIDATION=%2FwEWBALHkpPICQLq6ujxCAKu74e8CgLbgNGWDhGwePSQniauH%2Bus3CWjmz0dBm4v

我正在用 Qt 编写以下代码:

QNetworkAccessManager *manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)),
        this, SLOT(replyFinished(QNetworkReply*)));

QNetworkRequest request;
request.setUrl(QUrl("http://www.rwwa.com.au/cris/meetingdownload.aspx?meeting=15016"));
request.setRawHeader("Host", "www.rwwa.com.au");
request.setRawHeader("User-Agent", "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.16) Gecko/20110323 Ubuntu/10.10 (maverick) Firefox/3.6.16");
request.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
request.setRawHeader("Accept-Language", "en-us,en;q=0.5");
request.setRawHeader("Accept-Encoding", "gzip,deflate");
request.setRawHeader("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
request.setRawHeader("Keep-Alive", "115");
request.setRawHeader("Connection", "keep-alive");
request.setRawHeader("Referer", "http://www.rwwa.com.au/cris/meetingdownload.aspx?meeting=15016");
//request.setRawHeader("Cookie", "");
request.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
request.setRawHeader("Content-Length", "557");

reply = manager->get(request);
connect(reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
        this, SLOT(slotError(QNetworkReply::NetworkError)));

但是我不知道如何处理 EVENTTARGET 和 VIEWSTATE,以及我是否遵循了好的方法。

于 2011-04-17T18:48:54.737 回答