Hi all, i'm doing my own project where this script fetch content from remote server, get captcha, display to user to fill in then submit it. the problem is i can't get captcha for this site _http://abadijayaiklan.co.cc/pasang-iklan/ (remove underscore in front of url), its seems like their captcha using more complex session btw this is my code, i've try it with other site and works perfectly, just can't get it work for site above. <?php function open($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2'); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_COOKIE, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, "1"); curl_setopt($ch, CURLOPT_COOKIEFILE, "1"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); $result = curl_exec($ch); curl_close($ch); return $result; } function between($string, $start, $end) { $out = explode($start, $string); if(isset($out[1])) { $string = explode($end, $out[1]); return $string[0]; } return ''; } function get_captcha() { $url = 'http://abadijayaiklan.co.cc/pasang-iklan/'; $open = open($url); $code = between($open, '<img src="http://abadijayaiklan.co.cc/captcha.php', '">'); return 'http://abadijayaiklan.co.cc/captcha.php' . $code; } ?> <form action="" method="post"> <img src="<?php echo get_captcha(); ?>" border="0" /><br /> <input type="text" name="code" /><br /> <input type="submit" value="Submit" /> </form> PHP: or maybe i must save captcha first? but how to do it? i hope someone can help me out Thanks and regards Please not this is not for SPAM
Try: <?php function open($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2'); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_COOKIE, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, "1"); curl_setopt($ch, CURLOPT_COOKIEFILE, "1"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_REFERER, 'http://abadijayaiklan.co.cc/pasang-iklan/'); $result = curl_exec($ch); curl_close($ch); return $result; } preg_match('~http://abadijayaiklan\.co\.cc/captcha\.php\?VID=([0-9a-z]+)~', open('http://abadijayaiklan.co.cc/pasang-iklan/'), $a); ?> <form action="" method="post"> <img src="http://abadijayaiklan.co.cc/captcha.php?VID=<?php echo $a[1]; ?>" border="0" /><br /> <input type="text" name="code" /><br /> <input type="submit" value="Submit" /> </form> PHP:
Hi danx10, thanks for your reply, anyway, your code and mine success to get URL of captcha, but still captcha can't load, bcause cookies was changed, or anything else. i think we must save cookies temp and load captcha with cookies inside, but how? thanks
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2'); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_COOKIE, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__)."/cookie.txt"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_REFERER, 'http://abadijayaiklan.co.cc/pasang-iklan/'); $result = curl_exec($ch); curl_close($ch); return $result; PHP: di kaskus mang ga da yg bsa? Don't forget to include the cookies, when sending postfields
Blm coba d kkaskus, btw aku dah pernah pk yg kita save cookies ke file txt juga tapi tetep g bsa pusing juga euy .. english : Thanks bro, i've ever try similiar script but not working