yhi Posted May 22, 2014 Share Posted May 22, 2014 i want to make a webpage search want to make a script which search the existing webpage & echo them if response is 200 or 403 Link to comment https://forums.phpfreaks.com/topic/288668-help-in-php/ Share on other sites More sharing options...
trq Posted May 22, 2014 Share Posted May 22, 2014 And your question is? Link to comment https://forums.phpfreaks.com/topic/288668-help-in-php/#findComment-1480416 Share on other sites More sharing options...
joallen Posted May 22, 2014 Share Posted May 22, 2014 You can handle something like this using PHP and cURL. Here is a cURL process which will take an array of urls and process them: function requestData($urls){ // Create get requests for each URL $mh = curl_multi_init(); foreach($urls as $i => $url) { $ch[$i] = curl_init($url); curl_setopt($ch[$i], CURLOPT_RETURNTRANSFER, 1); curl_multi_add_handle($mh, $ch[$i]); } // Start performing the request do { $execReturnValue = curl_multi_exec($mh, $runningHandles); } while ($execReturnValue == CURLM_CALL_MULTI_PERFORM); // Loop and continue processing the request while ($runningHandles && $execReturnValue == CURLM_OK) { // Wait forever for network $numberReady = curl_multi_select($mh); if ($numberReady != -1) { // Pull in any new data, or at least handle timeouts do { $execReturnValue = curl_multi_exec($mh, $runningHandles); } while ($execReturnValue == CURLM_CALL_MULTI_PERFORM); } } // Check for any errors if ($execReturnValue != CURLM_OK) { trigger_error("Curl multi read error $execReturnValue\n", E_USER_WARNING); } // Extract the content foreach($urls as $i => $url) { // Check for errors $curlError = curl_error($ch[$i]); if($curlError == "") { $res[$i] = curl_multi_getcontent($ch[$i]); } else { $res[$i] = ''; } // Remove and close the handle curl_multi_remove_handle($mh, $ch[$i]); curl_close($ch[$i]); } // Clean up the curl_multi handle curl_multi_close($mh); // Print the response data return $res; } Hope that gets you in the right direction. Good Luck! Josh Link to comment https://forums.phpfreaks.com/topic/288668-help-in-php/#findComment-1480510 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.