Use Baidu to correct incorrect words or characters
// Simulate request post 2015-09-26function post ($ url, $ data, $ array = '0') {if ($ array = '0 ') // The browser information is null {$ array = array ("Referer: {$ url}", 'user-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) appleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.152 Safari/100');} $ ch = curl_init ($ url); curl_setopt ($ ch, CURLOPT_HEADER, 0 ); // Two lines dedicated to https // curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, FALSE); // curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt ($ ch, expires, 1); curl_setopt ($ ch, CURLOPT_TIMEOUT, 3); // Number of timeout seconds curl_setopt ($ ch, CURLOPT_POST, 1); curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ data ); curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ array); // line feed for sending the analog information array $ post_array = array ('Accept-Encoding: gzip '); $ curlsc = curl_exec ($ ch); // save as the variable curl_close ($ ch); Return $ curlsc;} // simulate the request get 2015-09-26function get ($ url, $ array = '0') {if ($ array = '0') // The browser information is null {$ array = array ('User-Agent: mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.152 Safari/100', "Referer: {$ url }",);} $ ch = curl_init ($ url); // initialize curl_setopt ($ ch, CURLOPT_HEADER, 0); // no header part is returned // curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, 1 ); // curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ array) is reported when automatic redirect is used; // A new line is required for sending the simulation information array $ post_array = array ('Accept-Encoding: gzip '); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); // returns a string instead of directly outputting the source code curl_setopt ($ ch, CURLOPT_TIMEOUT, 3 ); // timeout seconds $ curl = curl_exec ($ ch); curl_close ($ ch); return $ curl;} // use Baidu detection to correct the character $ url =" http://m.baidu.com/s?word= {$ M} "; $ url = get ($ url); if (strstr ($ url, 'correct-Q ')) {$ preg = '# class = "correct-q"> (. *) # iUs '; // # iUs'; preg_match_all ($ preg, $ url, $ zz); $ a = $ zz [1] [0]; echo "are you looking for {$ a} \ n? enter the correct name again. ";}Else {echo 'None ';}