我写了以下PHP代码:
$postdata = 'username=userXXXX&password=passXXXX';
$ch = curl_init('website.com/user/login');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)');
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$string = curl_exec ($ch);
curl_close($ch);
//print_r($string);
有时当我重新加载脚本6-7次时,我必须完成一个Captcha。
我需要什么?我需要把catpcha放到我的脚本中,如果它出现就手动完成它。
验证码有HTML标签:
<div class="content-bg-bottom">
<h2>Security Code</h2>
<div class="inner-form-border">
<div class="inner-form-box">
<h3>Confirm the Login</h3>
<p>Please write the following captcha code for get into your account.</p>
<form name="captchaForm" id="captchaForm" action="http://website.com/captcha" method="post">
<div id="captchaContainer">
<script type="text/javascript">
/* <![CDATA[ */
$(document).ready(function() {
$('#reloadCaptcha').bind('click', function() {
var d = new Date();
$('#captchaImage').attr('src', 'http://website.com/captcha/create?' + d.getTime());
});
});
/* ]]> */
<label for="answer">Security Code: *</label>
<input class="validate[required]" id="answer" name="answer" title="" value="" maxlength="10" type="text">
</div>
<input id="submitBtn" class="btn-big" name="SubmitCaptchaForm" value="Trimite" type="submit">
<script type="text/javascript">
</script>
</form>
<p id="regLegend">* obligatory fields</p>
</div>
</div>
</div>