Charmees Posted December 27, 2010 Share Posted December 27, 2010 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 https://forums.phpfreaks.com/topic/222737-curl-login-and-get-page-source-code/ Share on other sites More sharing options...
Unirawan Posted December 27, 2010 Share Posted December 27, 2010 http://pokerrpg.com/login.php is the url you need to send the login post data to, not http://pokerrpg.com/ Link to comment https://forums.phpfreaks.com/topic/222737-curl-login-and-get-page-source-code/#findComment-1151811 Share on other sites More sharing options...
Charmees Posted December 27, 2010 Author Share Posted December 27, 2010 woohoo, wow thank you, ive been messing with this for 2 days now!! Link to comment https://forums.phpfreaks.com/topic/222737-curl-login-and-get-page-source-code/#findComment-1151813 Share on other sites More sharing options...
the182guy Posted December 27, 2010 Share Posted December 27, 2010 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 https://forums.phpfreaks.com/topic/222737-curl-login-and-get-page-source-code/#findComment-1151816 Share on other sites More sharing options...
Charmees Posted December 27, 2010 Author Share Posted December 27, 2010 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 https://forums.phpfreaks.com/topic/222737-curl-login-and-get-page-source-code/#findComment-1151840 Share on other sites More sharing options...
Charmees Posted December 28, 2010 Author Share Posted December 28, 2010 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 https://forums.phpfreaks.com/topic/222737-curl-login-and-get-page-source-code/#findComment-1152177 Share on other sites More sharing options...
the182guy Posted December 28, 2010 Share Posted December 28, 2010 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 https://forums.phpfreaks.com/topic/222737-curl-login-and-get-page-source-code/#findComment-1152179 Share on other sites More sharing options...
Charmees Posted December 28, 2010 Author Share Posted December 28, 2010 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 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 https://forums.phpfreaks.com/topic/222737-curl-login-and-get-page-source-code/#findComment-1152237 Share on other sites More sharing options...
BlueSkyIS Posted December 28, 2010 Share Posted December 28, 2010 2) how can i execute javascript with php or curl? you can't. Link to comment https://forums.phpfreaks.com/topic/222737-curl-login-and-get-page-source-code/#findComment-1152246 Share on other sites More sharing options...
Charmees Posted December 28, 2010 Author Share Posted December 28, 2010 but can i somehow keep the session, so i can click links in browser? Link to comment https://forums.phpfreaks.com/topic/222737-curl-login-and-get-page-source-code/#findComment-1152253 Share on other sites More sharing options...
Charmees Posted December 28, 2010 Author Share Posted December 28, 2010 sorry for double post, but do not see edit button here or maybe some other language is can do, what i need ? ajax or something? Link to comment https://forums.phpfreaks.com/topic/222737-curl-login-and-get-page-source-code/#findComment-1152276 Share on other sites More sharing options...
BlueSkyIS Posted December 28, 2010 Share Posted December 28, 2010 they obviously designed the application to prevent exactly what you are trying to do. if they have half a brain, you won't be able to do what you are trying to do. i think they have more than half a brain. Link to comment https://forums.phpfreaks.com/topic/222737-curl-login-and-get-page-source-code/#findComment-1152291 Share on other sites More sharing options...
lastkarrde Posted December 28, 2010 Share Posted December 28, 2010 Theres no way to bypass CAPTCHAs. You have to either solve them yourself or set up a system (image recognition) to solve them. Link to comment https://forums.phpfreaks.com/topic/222737-curl-login-and-get-page-source-code/#findComment-1152292 Share on other sites More sharing options...
Charmees Posted December 29, 2010 Author Share Posted December 29, 2010 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 https://forums.phpfreaks.com/topic/222737-curl-login-and-get-page-source-code/#findComment-1152482 Share on other sites More sharing options...
the182guy Posted December 29, 2010 Share Posted December 29, 2010 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 https://forums.phpfreaks.com/topic/222737-curl-login-and-get-page-source-code/#findComment-1152497 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.