How to download a csv file (behind a __dopostback) with Qt
I need a function to download csv files from "Meeting Results" in: http://www.rwwa.com.au/cris/meetingdownload.aspx?meeting=15014
The problem is that you need to click the "Meeting Results" link to get the file.
This link has the following associated URL: javascript:__doPostBack('ctl00$ContentPlaceHolderMain$linkButtonResults','')
How can I simulate the click to download the file in Qt?
Note: I checked the HTTP Example from Qt but as the csv file has n开发者_Go百科ot a direct link, I don't know how to download it.
Thank you all for your time and answers. Best regards
In other words, the HTTP obtained with WireShark is (Qt code below):
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
I am writing in Qt the following code:
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)));
But I don't know how to deal with EVENTTARGET and VIEWSTATE, and whether I am following the good approach.
精彩评论