curl-library
Unsuccessful Login
Date: Mon, 15 Nov 2010 18:12:47 -0800
I'm quite unfamiliar with the Internet technologies and I cannot dedicate
much time to those. Hence, I'm here seeking some help.
What I need:
Instead of logging in manually, I'm trying with libcURL to login to ETrade
and retreive the data I need.
The URL of the ETrade login page is: *https://us.etrade.com/e/t/user/login*
While logging in manually, I see that Mozilla posts the following data
string:
*
USER=myUSRid&PASSWORD=myPASSwd&TARGET=%2Fe%2Ft%2Fpfm%2Fportfolioview&Logon.x=50&Logon.y=16
*
The problem:
I cannot retrieve/calculate/set the values for Logon.x and Logon.y
The numbers assigned to them change every time a login is attempted,
blocking the access in case they are invalid.
It seems that, before assembling the data string to post, the client has to
receive back from the host some info/data that allow the setting of the
values for Logon.x and Logon.y
I tracked the cookies and I could not find any hint. I also checked the Java
code in the HTML of the login page: no hints from it.
Here below is the code I'm using as trial.
I would appreciate any help, including some pointer to the proper
documentation, if any. Thank You.
=====================================
#include <curl/curl.h>
#include <curl/easy.h>
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
int main(void)
{
const string LoginPage = "https://us.etrade.com/e/t/user/login";
const string PostLogin =
"USER=myUSRid&PASSWORD=myPASSwd&TARGET=%2Fe%2Ft%2Fpfm%2Fportfolioview&Logon.x=50&Logon.y=16";
CURL *sessionA;
CURLcode result;
FILE *NULLFILE, *CookieFile, *HeaderFile;
const char *CookiesBag = "Cookies.txt";
CookieFile = fopen(CookiesBag,"w");
HeaderFile = fopen("Header.html","w");
NULLFILE = fopen("/dev/null", "w");
curl_global_init(CURL_GLOBAL_ALL);
sessionA = curl_easy_init();
if(sessionA) {
curl_easy_setopt(sessionA, CURLOPT_VERBOSE, 1);
curl_easy_setopt(sessionA, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(sessionA, CURLOPT_COOKIELIST, "ALL"); // erase
"ALL" cookies
curl_easy_setopt(sessionA, CURLOPT_COOKIEJAR, CookiesBag);
curl_easy_setopt(sessionA, CURLOPT_COOKIEFILE, CookiesBag);
curl_easy_setopt(sessionA, CURLOPT_WRITEHEADER, HeaderFile);
curl_easy_setopt(sessionA, CURLOPT_POSTFIELDS, PostLogin.c_str());
curl_easy_setopt(sessionA, CURLOPT_URL, LoginPage.c_str());
result = curl_easy_perform(sessionA);
curl_easy_cleanup(sessionA);
}
return 0;
}
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-11-16