我有一个简单的 php curl 函数,它可以转到另一个站点(不属于我)并填写字段并正常工作,唯一的事情是我无法让它选中一个复选框。我似乎找不到答案。
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, 1);
$searchCriteria = array(
'historicalMatches' => $_POST['historicalMatches'], //the checkbox
'firstName' => $_POST['firstName'],
'middleName' => $_POST['middleName'],
'lastName' => $_POST['lastName'],
'suffix' => $_POST['suffix'],
'age' => $_POST['age'],
etc..);
curl_setopt($ch, CURLOPT_POSTFIELDS, $searchCriteria);
我尝试将值设置为 1 并打开并检查。另一个页面上复选框的 html 是:
<input type="checkbox" name="historicalMatches" value="on">
我需要做的就是确保每次都检查它。所以我可以添加第二个
curl_setopt($ch, CURLOPT_POSTFIELDS, 'check the box');
只是点击我只是想不通的框。谢谢