NorbertBehrens
Programmer
Hi,
I try to get data from a password protected webpage and need a little help.
At first I want to describe the situation in the browser.
When I call the webpage, I got a page with a little login screen. This
is realized by some javascript code. I fill in the username and
password, click on 'login' and voila, there are my wanted data.
I looked at the javascript code an noticed the names of the fields. I
tried to call the webpage directly with:
... and it works fine.
Now I had to do the same in my MFC-Projekt but I failed. I was
unsuccessful with the following two attempts
#################
## First Attempt
#################
********************************************************************************************************
...
********************************************************************************************************
#################
## Second Attempt
#################
...
********************************************************************************************************
Any Idea's?
ciao
Norbert
I try to get data from a password protected webpage and need a little help.
At first I want to describe the situation in the browser.
When I call the webpage, I got a page with a little login screen. This
is realized by some javascript code. I fill in the username and
password, click on 'login' and voila, there are my wanted data.
I looked at the javascript code an noticed the names of the fields. I
tried to call the webpage directly with:
... and it works fine.
Now I had to do the same in my MFC-Projekt but I failed. I was
unsuccessful with the following two attempts
#################
## First Attempt
#################
********************************************************************************************************
...
Code:
CInternetsession InternetSession(_T("AppName"),1, INTERNET_OPEN_TYPE_PRECONFIG);
char Url = "<address>?<NameOfUserField>=<username>&<NameOfPasswordField>=<password>&action=<actionname>";
CString strServerName; // Server
CString strObject; // directory
INTERNET_PORT nPort; // port
DWORD dwServiceType; // accesstype
AfxParseURL(Url, dwServiceType, strServerName, strObject, nPort)
DWORD dwHttpRequestFlags = INTERNET_FLAG_RELOAD;
CHttpFile *pHttpFile = pHttpConnection->OpenRequest(CHttpConnection::HTTP_VERB_GET,// or HTTP_VERB_POST
strObject, NULL, 1, NULL, NULL,
dwHttpRequestFlags);
pHttpFile->SendRequest();
CString sz;
while (pHttpFile->ReadString(sz)){
...
}
#################
## Second Attempt
#################
...
Code:
CInternetsession InternetSession(_T("AppName"),1, INTERNET_OPEN_TYPE_PRECONFIG);
char Url = "<Only_Address_without_parameter>";
CString strServerName; // Server
CString strObject; // directory
INTERNET_PORT nPort; // port
DWORD dwServiceType; // accesstype
AfxParseURL(Url, dwServiceType, strServerName, strObject, nPort)
DWORD dwHttpRequestFlags = INTERNET_FLAG_RELOAD;
CHttpFile *pHttpFile = pHttpConnection->OpenRequest(CHttpConnection::HTTP_VERB_GET,// or HTTP_VERB_POST
strObject, NULL, 1, NULL, NULL,
dwHttpRequestFlags);
CString szHeader = _T("<NameOfUserField>=<username>&<NameOfPasswordField>=<password>&action=<actionname>");
pHttpFile->AddRequestHeaders(szHeader);
pHttpFile->SendRequest();
CString sz;
while (pHttpFile->ReadString(sz)){
...
}
Any Idea's?
ciao
Norbert