웹 페이지 (로컬이 아닌)에 POST를 수행하고 html을 반환하기 위해 cUrl을 사용하고 있습니다.PHP/Curl - 루프 및 POST 버퍼가 지워지지 않음
이 작업을 여러 번 수행해야하므로 cUrl 코드가 while 루프에 있습니다. 이상한 일이 있습니다 : 처음에는 예상대로 작동하지만 이후에는 POST 버퍼를 지우지 않는 것 같습니다. (나는 close_curl ($ ch)을 수행하고 POST를 통과 한 모든 데이터는 정확합니다.)
예를 들어, 텍스트 필드 중 하나가 "ANY"가되어야합니다. 그러나 두 번째로 "ANY, ANY"를 통과합니다.
이 문제가 클리핑되지 않은 POST 버퍼에 있다고 수정합니까? 어떻게 해결할 수 있습니까?
SORRY : 여기 내가이 작업을 수행 할 때 루프 $의 resultTable를 통해 첫 번째 시간은 60 개 항목이 ...
$someResults = mysql_query($someSQL);
while($record = mysql_fetch_array($alertResults)){
$url = "http://something.com/searchResults.asp";
$someV = "Hi";
$fields = array(
//date to post.
);
foreach($fields as $key=>$value){
$fields_string .= $key .'='. $value . '&';
}
rtrim($fields_string,'&');
$ch = curl_init();
$userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)';
curl_setopt($ch,CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_FORBID_REUSE, true);
ob_start();
$html = curl_exec($ch);
curl_close($ch);
$dom = new DOMDocument();
@$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$resultTable = $xpath->evaluate("/html/body//table");
}
을 코드의 단축 버전이고. 하지만 매번 거기 (같은 URL을 사용) 후 0 항목이 있습니다. POST 버퍼가 지워지지 않고 모든 것이 이전 POST 데이터의 ontop에 게시되기 때문입니다.
루프를 통해 매번 POST 데이터를 지울 수 있습니까?
당신이 루프/컬의 코드를 게시 할 수있는 시도 할 것 같습니다? – Oli
@Oli에 따르면, 문제가 무엇인지 평가하려고한다면 코드를 볼 필요가 있습니다. :-) –
추가했습니다! 도움말은 대단히 감사하겠습니다. –