#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QUrl>
#include <QtGui>
#include <QtWebKit>
#include <QNetworkAccessManager>
#include <QDebug>
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
m_manager = new QNetworkAccessManager(this);
m_manager->setCookieJar(new QNetworkCookieJar());
connect(m_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
QUrl pUrl
= QUrl("http://epay.ste.gov.sy/LandlineLogin.aspx");
QString number
=ui
->lineEdit
->text
();
const char* USERAGENT = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.1) Gecko/20100101 Firefox/6.0.1";
QNetworkRequest request;
request.setUrl(pUrl);
request.setRawHeader("POST", "/LandlineLogin.aspx HTTP/1.1");
request.setRawHeader("Host", "epay.ste.gov.sy");
request.setRawHeader("User-Agent", USERAGENT);
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("Connection","keep-alive");
request.setRawHeader("Content-Type","application/x-www-form-urlencoded");
request.setRawHeader("Content-Length","300");
params.addQueryItem("__VIEWSTATE", "/wEPDwUKMTYzOTMwODYxMGRkVEeVekMk3/sAdBfyPomrEotg83zpqXlu6s2KsGpNdDQ=");
params.addQueryItem("__EVENTVALIDATION","/wEWBQKBt4mpDAKKo/qFAgLez+mJBAL07o6PBgKUiafMAYIx/ItiiybnhfcGZb1TAJ1J1fR3xF9e7rPxGcXQT59x");
params.addQueryItem("ctl00$hdCulture","ar-SY");
params.addQueryItem("ctl00$cphMain$txtPhoneNumber",number);
params.addQueryItem("ctl00$cphMain$btnLogin",number);
data.append(params.toString());
//data.remove(0,1);
qDebug() << "this data" << data;
m_manager->post(request,data);
}
void MainWindow::replyFinished(QNetworkReply* pReply)
{
qDebug() << "this" << str.toAscii();
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QUrl>
#include <QtGui>
#include <QtWebKit>
#include <QNetworkAccessManager>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
m_manager = new QNetworkAccessManager(this);
m_manager->setCookieJar(new QNetworkCookieJar());
connect(m_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
QUrl pUrl = QUrl("http://epay.ste.gov.sy/LandlineLogin.aspx");
QString number=ui->lineEdit->text();
const char* USERAGENT = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.1) Gecko/20100101 Firefox/6.0.1";
QNetworkRequest request;
request.setUrl(pUrl);
request.setRawHeader("POST", "/LandlineLogin.aspx HTTP/1.1");
request.setRawHeader("Host", "epay.ste.gov.sy");
request.setRawHeader("User-Agent", USERAGENT);
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("Connection","keep-alive");
request.setRawHeader("Content-Type","application/x-www-form-urlencoded");
request.setRawHeader("Content-Length","300");
QByteArray data;
QUrl params;
params.addQueryItem("__VIEWSTATE", "/wEPDwUKMTYzOTMwODYxMGRkVEeVekMk3/sAdBfyPomrEotg83zpqXlu6s2KsGpNdDQ=");
params.addQueryItem("__EVENTVALIDATION","/wEWBQKBt4mpDAKKo/qFAgLez+mJBAL07o6PBgKUiafMAYIx/ItiiybnhfcGZb1TAJ1J1fR3xF9e7rPxGcXQT59x");
params.addQueryItem("ctl00$hdCulture","ar-SY");
params.addQueryItem("ctl00$cphMain$txtPhoneNumber",number);
params.addQueryItem("ctl00$cphMain$btnLogin",number);
data.append(params.toString());
//data.remove(0,1);
qDebug() << "this data" << data;
m_manager->post(request,data);
}
void MainWindow::replyFinished(QNetworkReply* pReply)
{
QByteArray data=pReply->readAll();
QString str(data);
qDebug() << "this" << str.toAscii();
}
To copy to clipboard, switch view to plain text mode
Bookmarks