dtstnjl898781429 2012-07-14 00:48
浏览 45

使用php将数据和验证码发布到网站

I am trying to post data to a url from php. I have checked codes like below from this forum.

$url = 'http://www.someurl.com';  
$myvars = 'myvar1=' . $myvar1 . '&myvar2=' . $myvar2;  
$ch = curl_init( $url );  
curl_setopt( $ch, CURLOPT_POST, 1);  
curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);  
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);  
curl_setopt( $ch, CURLOPT_HEADER, 0);  
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);  
$response = curl_exec( $ch );  

But my target site has a captcha as well. How do I load the captcha on my php and submit it with captcha answer?

I had a look at the link. Didn't get the final solution though. How to retrieve captcha and save session with PHP cURL?
also How to retrieve captcha and save session with PHP cURL? and http://hungrycoder.xenexbd.com/general/how-to-submit-a-form-using-php-curl-fsockopen.html

My target site has code like below

<form method="post" action="action_form.php" name="frm_sms" id="frm_sms"> < input     type="hidden" name="nav" value="sms" />   

I don't need to bypass the captcha but I only want to load a neat form and captcha img but no other junk and submit info with captcha answer.

  • 写回答

1条回答 默认 最新

  • duanpanyang1962 2012-07-14 01:34
    关注

    You will have to first fetch the captcha image using cURL and save the contents of any session cookie that it sets, or note the captcha identifier (depends on how their captcha works) and then save a copy of the image to your server.

    Then in your form display the copy of the captcha to your visitor. Add an input field for them enter the captcha solution add their input to your $myvars string, and send the cookie or captcha id that was set with the image along with the form post.

    That's one way you can forward their captcha on to your user. Or maybe they have an API you can sign up for.

    评论

报告相同问题?

悬赏问题

  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)