开发者

Qt - webkit - how to login programmatically

开发者 https://www.devze.com 2023-04-11 05:25 出处:网络
I am making a web scraper. In that I need to login into my email account programatically. Can anybody say how to achieve that. I think \"QNetworkAccesManager\" and it\'s \"get()\" can make this. But,

I am making a web scraper. In that I need to login into my email account programatically. Can anybody say how to achieve that. I think "QNetworkAccesManager" and it's "get()" can make this. But, I don't know exactly. Somebody please shed a l开发者_如何学运维ight on this issue.

Note: I am using Qt-4.7.2 + C++


If the login is done in a web page then you should perform a post operation using QNetworkAccessManager::post() including the login fields in the data.

For instance:

QNetworkAccessManager network;
QByteArray loginData("user=myName&password=myPassword");
QNetworkRequest request(QUrl("http://mySite.com/login"));
QNetworkReply* pReply(network.post(request, loginData);

If the login is done via HTTP authentication method then you should connect the signal QNetworkAccessManager::authenticationRequired to one slot and fill the authentication data there.

0

精彩评论

暂无评论...
验证码 换一张
取 消