Jump to content

[SOLVED] parsing pages behind a user login...


interpim

Recommended Posts

So, I built a parser that will parse the HTML of a page, but the page I want to parse requires a username and a password to get to it.

 

I have a username and password, but I cannot get my script to access the pages.

 

I have tried cURL (maybe incorrectly) and it doesn't work...

I have tried passing the variables to the page which it looks like the page requires me to do and it doesn't work

 

I am trying to login to this page here http://realmwar.warhammeronline.com/realmwar/Index.war

 

The parser just gets redirected back to this page when it cycles through the URL's I pass to it instead of the actual pages, indicating it isn't logging in.  I am using WAMPP on the same machine that I have logged into the site with, but I still cannot get to it... can anyone offer any suggestions?

Link to comment
Share on other sites

hmmm... can you explain the cookie jar?  I have a cURL set up already for it.

$URL="http://realmwar.warhammeronline.com/realmwar/Index.war";
$ch = curl_init();   
curl_setopt($ch, CURLOPT_URL,"$URL"); 
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "war_username=$user_name&war_password=$pword");curl_exec ($ch);    
curl_close ($ch); 

Link to comment
Share on other sites

First off, you need to be posting to the actual login URL

Which is this: http://realmwar.warhammeronline.com/realmwar/UserLoginAuthentication.war

Then, you need to be passing the correct parameters, which is actually user and password like so:

 

user=$user_name&password=$pword in the postfields option

 

Then for the cookies and logging in, you need to add

 

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefilename");

curl_setopt($curl, CURLOPT_COOKIEJAR, "cookiefilename");

 

Then use curl_exec() and assign it to a variable so the output of the login page is stored like so

 

$pageResults = curl_exec($ch);

 

From there you can change the CURLOPT_URL to any page that requires you to be logged in and it should work.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.