Find correct url target in cURL login?

Dear all,
I’m trying login to https://www.dailyfx.com/login with username & password (for security reason, I’m not show correct information here).
And i’m also try with URL target : https://plus.dailyfx.com/tnews/home.do?ib=dailyfx4 . but It’s not work

How to find correct $target URL ?
Please help.

Thanks so much

My PHP script:

$target = ‘https://www.dailyfx.com/login’;
$curl = curl_init($target);

curl_setopt($curl, CURLOPT_COOKIEJAR, ‘cookies.txt’);
curl_setopt($curl, CURLOPT_COOKIEFILE, ‘cookies.txt’);
//
//Some cURL code i’m not posting here :slight_smile:
//
$post = ‘j_username=myusername&j_password=mypassword&cookieuser=1’;
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);

$response = curl_exec($curl);
if ($response) {
echo ‘Login success!’;
} else echo ‘Cannot login!’;
curl_close($curl);

Looking at the page source of the login page, it looks as if the target URL is correct, so possibly the site is doing some additional verification to see whether you’re a proper login or not. Maybe in an attempt to prevent exactly what you’re trying to do. Can you expand on “not work”?

Hi,

Thanks for your reply.
I get message Cannot login for this code. May i ask which $target URL is correct ?
This site login not need verification (by captcha or…) , just using username and password.
Please help me to add the missing code.

Many thanks.

Well, the page source that anyone can see when they open it in a browser shows:

<form data-toggle="validator" id="login-form" class="login-form" action="/login" method="post">

so I’d say the target you have in your first post is correct. But then, if you look a bit further down, it has this bit of JavaScript:

(function(jq) {
  jq("#login-form").submit(function(event){
  event.preventDefault();
  DFX.Authentication.login();
  });
  }(window.jQuery));

so my guess is that the DFX.Authentication.login() call actually does the work, so it’s a case of finding that function and replicating what it does.

BUT - as this is user authentication and logging in to what I presume is a paid web site, there’s a strong possibility that they’ll have taken many, many steps to prevent you from logging in with your own code. You might also find that if you’ve paid for access, their terms and conditions might prevent you from what you’re trying to do.

Do they not offer an API to retrieve whatever data you’re trying to retrieve? The trouble with replicating their login procedures in code is that they can change them any time they want to, then you need to write some more code to try to get around them. Using an API usually means they won’t do that.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.