Получите капчу с помощью Curl и отправьте данные и получите результаты

Так что базовый я новичок в php. Я хочу получить catpcha с веб-сайта. Затем я хочу показать его на моей веб-странице и отправить небольшой запрос на сообщение и получить результаты. Сайт, о котором я говорю, – http://www.bollywoodmotion.com/mobile-tracker-with-name.html

Я хочу получить код с этой страницы на мою страницу и ввести captcha на моей странице и отправить то же самое, что и на моей странице. Я сделал это в программном обеспечении с помощью c #. Мне также нужна веб-версия, так как я понятия не имею о php. Любой способ, которым я пытался искать и получил завиток, – лучший вариант для меня. Так может кто-нибудь помочь мне с образцом PHP-кода.

Это запрос, сделанный им.

http://www.bollywoodmotion.com/mobile-tracker-process.html

POST /mobile-tracker-process.html HTTP/1.1 Host: www.bollywoodmotion.com User-Agent: Mozilla/5.0 (Windows NT 6.2; rv:26.0) Gecko/20100101 Firefox/26.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Referer: http://www.bollywoodmotion.com/mobile-tracker-with-name.html Cookie: __utma=164959532.607980600.1392265746.1392293744.1392969352.5; __utmz=164959532.1392265754.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); PHPSESSID=t37p2pqeclbmc2tfvd8tt18qs5; __utmb=164959532.2.9.1392969356013; __utmc=164959532 Connection: keep-alive Content-Type: application/x-www-form-urlencoded Content-Length: 36 num=960xxxxxx&6_letters_code=hy5xjf 
 HTTP/1.1 200 OK Date: Fri, 21 Feb 2014 07:56:11 GMT Server: Apache Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Content-Encoding: gzip Set-Cookie: dle_user_id=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.bollywoodmotion.com; httponly Set-Cookie: dle_password=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.bollywoodmotion.com; httponly Set-Cookie: dle_hash=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.bollywoodmotion.com; httponly Last-Modified: Mon, 16 Sep 2013 23:55:25 GMT Keep-Alive: timeout=10, max=30 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html 

Solutions Collecting From Web of "Получите капчу с помощью Curl и отправьте данные и получите результаты"

Это был мой вопрос о SO, для которого я не получил ответа. Однако сейчас у меня есть ответ. Это прекрасный пример, который вы хотите. Я получил капчу, используя URL-адрес captcha-кода в исходном коде веб-страницы, который также содержит ваш сайт. Извлеките это изображение из URL-адреса captcha-url, используя between (). Затем выполните сеанс и снова отправьте запрос. что вы должны отправить данные в URL-адрес формы, а не на страницу.

 <?php $cookie="cookie.txt"; 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,$cookie); curl_setopt($ch, CURLOPT_COOKIEFILE,$cookie); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt ($ch, CURLOPT_REFERER, $url); $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]); echo $string[0]; return $string[0]; } return ''; } function get_captcha() { $url = 'https://academics.vit.ac.in/student/stud_login.asp'; $open = open($url); $code = between($open, '<img src='https://academics.vit.ac.in/student/captcha.asp', '">'); return 'https://academics.vit.ac.in/student/captcha.asp' . $code; } function rahul() { $capth=htmlspecialchars($_POST['code']); echo $capth; $username="xyz"; $password="abc"; $url=url of the form in which you want to submit your data; $cookie="cookie.txt"; $veri=$capth; $com="Login"; $postdata = "regno=".$username."&passwd=".$password."&vrfcd=".$veri."&submit=".$com; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); curl_setopt ($ch, CURLOPT_TIMEOUT, 60); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookie); // <-- add this line curl_setopt ($ch, CURLOPT_REFERER, $url); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt ($ch, CURLOPT_POST, 1); $result = curl_exec ($ch); echo $result; $data = curl_exec($ch); } ?> <html> <body> <form action="" method="post"> <img src="<?php echo get_captcha(); ?>" border="0" /><br /> <input type="text" name="code" value="<?= isset($_POST['code']) ? htmlspecialchars($_POST['code']) : '' ?>" /><br /> <input type="submit" name="submit" value="submit"/> </form> <?php if(isset($_POST['submit'])) { rahul(); } ?> </body> </html>