I have listed two solutions of Baidu
1. Add the ban on https in curl. However, there is no response
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false);
2. Add
to the http.conf of apacheEnableSendfile off
EnableMMAP off
both methods are of no avail. I don"t grab a large number of pages. I just grab a search page. How could this happen?
my win server
here is my code:
$url = "http://www.baidu.com/s?wd=" . urlencode( "site:" . $input . $key );
$data = array();
$header = array();
$response = $this->doCurl( $url, $data, $header, 5 );
public function doCurl( $url, $data = array(), $header = array(), $timeout = 30 ) {
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_HTTPHEADER, $header );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_TIMEOUT, $timeout );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false);
$response = curl_exec( $ch );
if ( $error = curl_error( $ch ) ) {
die( $error );
}
curl_close( $ch );
return $response;
}