Usually, in the Baidu keyword search appears in the list page, click on the target link, but when the jump is Baidu address, after Baidu analysis, really jump to the target page.
In the SEO, often need to look at their own site rankings, and do not want to manually go to point manual every day, the following methods can be used to get the target address.
The principle is quite simple: simulate the request and get the real address.
<?PHP$url= "Http://www.baidu.com/link?url=nS2MGJqjJ4zBBpC8yDF8xDh8vibi1lVeE7gGr9UONBu";$info=Parse_url($url);$fp=Fsockopen($info[' Host '], 80,$errno,$errstr, 30);fputs($fp, "GET {$info[' Path ']}? {$info[' Query ']} Http/1.1\r\n ");fputs($fp, "Host: {$info[' Host ']} \ r \ n ");fputs($fp, "connection:close\r\n\r\n");$rewrite= ' '; while(!feof($fp)) { $line=fgets($fp); if($line! = "\ r \ n" ) { if(Strpos($line, ' location: ')!==false) { $rewrite=Str_replace(Array("\ r", "\ n", "Location:"), ",$line); } }Else { Break; }}Var_dump($rewrite);//results shown: string "http://www.google.com/"?>
Resolves http://www.baidu.com/link?url=nS2MGJqjJ4zBBpC8yDF8xDh8vibi1lVeE7gGr9UONBu to http://www.google.com/
Parse the URL of Baidu search result link, get the real URL