Jump to content

cURL login and get page source code


Charmees
 Share

Recommended Posts

well basically im trying to do that the 'subject says.

ive done my homework and had around 10 examples of using curl, but none of them worked in my case.

this is the final code i'm using

 

<?php
$cookiefile = '/temp/cookies.txt';


#2 ways ive tried doing

#$data = array('edit[username]' => 'REMOVED', 'edit[password]' => 'REMOVED', 'edit[submit]' => 'Login');
$data = array('username] => 'REMOVED', 'password' => 'REMOVED', 'submit' => 'Login');




$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'http://pokerrpg.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile);

curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

curl_exec($ch);

curl_setopt($ch, CURLOPT_URL, 'http://pokerrpg.com/furniture_store.php');
$contents = curl_exec($ch);
$headers = curl_getinfo($ch);

echo $contents;

curl_close($ch);
unlink($cookiefile);
?>

 

im not sure about the cookie file, but i just made a txt file to that location. and empty txt file.  hope it's fine.

 

the page i'm trying is http://pokerrpg.com, you can even look the source code that both of these fields do exist.

 

when i run it, the output is a login page without logging in, so it does not log in.  :(

Link to comment
Share on other sites

woohoo, wow thank you, ive been messing with this for 2 days now!!

 

Is it within their terms of website use to create login bots? Using the code above you'll get flagged quickly as a bot because you're not sending a user agent string. cURL does not send a user agent by default and some web servers will simply reject the request as it's clearly not a human.

Link to comment
Share on other sites

woohoo, wow thank you, ive been messing with this for 2 days now!!

 

Is it within their terms of website use to create login bots? Using the code above you'll get flagged quickly as a bot because you're not sending a user agent string. cURL does not send a user agent by default and some web servers will simply reject the request as it's clearly not a human.

 

thank you, did not even think about that

will this help me out?

$useragent = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko)
Chrome/8.0.552.224 Safari/534.10';
$ref = 'http://pokerrpg.com';
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);

#furthermore, should i also define referrer?

curl_setopt($ch, CURLOPT_REFERER, $ref);

 

Link to comment
Share on other sites

okay now i have few problems, first of all.

 

1) after i curl.exec(), i get my webpage, i see it on browser but if i try to click on any links or buttons on my browser, it just logs me out

 

2) how can i execute javascript with php or curl? well im on my page with curl and i want to click on a link, but this link goes here:

 

<a href="javascript:human_test(717080039825, 972972262)">

 

can i execute it somehow?

Link to comment
Share on other sites

I don't see the point in pulling the source code for a page, then printing it out so the page displays, then clicking through the links on the page. Why?

 

Anyway about the link, you need to have a look at the source of the human_test() function to see what it's doing. Your web browser will execute the javascript.

 

The reason you are logged out when clicking any links is because cURL has created the session and it has the session ID as a cookie, clicking a link in your browser will be using a seperate session and the browser won't be sending the authenticated session ID.

Link to comment
Share on other sites

well basically its a site, where every 30 minutes new items come that i can buy, and everyone fight for the best ones

 

1) so i download source code and search for the best item according to rarity ( yes i can get it from source code )

2) i click on buy ( thats the javascript thing ) and that opens a simple flash human control window, here i must click on blue ring, then the item is bought

blue.png

 

so im this far:

i read source code and get the best item, also i have the link for buying the best item :

<a href="javascript:human_test(717161520400, 714999581)">Buy</a>

 

what i discovered that, if i dont press on blue ring, then i will be thrown to this page. and it says i failed the test

http://pokerrpg.com/furniture_store.php?page=buy&id=717161520400&id2=673611685&t=1293559676&id=717161520400&id2=0&getRandom=[type+Function]

 

 

Link to comment
Share on other sites

Theres no way to bypass CAPTCHAs. You have to either solve them yourself or set up a system (image recognition) to solve them.

 

well actuallly i'm not trying to solve captcha..i will explain

 

1)there will be new products in the shop every 30 days and everyone will be racing to get them

2)so i read the source, find the best item and click on it

3) then the captcha pops out and i can finish the captcha by myself, i just need it to pop the captcha up within few seconds.

 

so far i have the best item and it's link, i just need a way to pop it up

Link to comment
Share on other sites

You can inject cookies into chrome because it uses a simple SQLite database to maintain it's cookies, the problem would be is Chrome keeps the cookies in memory instead of reading the database on each page request (for speed), so you would have to restart Chrome before the new cookie is picked up.

 

You could echo out the session ID that you need, and then using Opera as your browser, you can manually modify the session ID so change it to the one the php code has echoed. I believe Opera allows you to modify cookies in realtime.

Link to comment
Share on other sites

This thread is more than a year old.

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.

 Share

×
×
  • 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.