php获取网站关键词
程序员文章站
2022-04-23 11:01:58
...
1. [代码]php代码
<?php $_SERVER['HTTP_REFERER']='http://www.baidu.com/s?wd=http://www.php.cn/'; echo save_www_iiwnet_com_keyword('http://www.baidu.com/s?wd=http://www.php.cn/','http://www.baidu.com/s?wd=http://www.php.cn/'); function save_www_iiwnet_com_keyword($domain,$path){ if(strpos($domain, 'google.com.tw')!==false && preg_match('/q=([^&]*)/i',$path,$regs)){ $searchengine = 'GOOGLE *'; $keywords = urldecode($regs[1]); // google * } if(strpos($domain,'google.cn')!==false && preg_match('/q=([^&]*)/i',$path,$regs)){ $searchengine = 'GOOGLE CHINA'; $keywords = urldecode($regs[1]); // google china } if(strpos($domain,'google.com')!==false && preg_match('/q=([^&]*)/i',$path,$regs)){ $searchengine = 'GOOGLE'; $keywords = urldecode($regs[1]); // google }elseif(strpos($domain,'baidu.')!==false && preg_match('/wd=([^&]*)/i',$path,$regs)){ $searchengine = 'BAIDU'; $keywords = urldecode($regs[1]); // baidu }elseif(strpos($domain,'baidu.')!==false && preg_match('/word=([^&]*)/i',$path,$regs)){ $searchengine = 'BAIDU'; $keywords = urldecode($regs[1]); // baidu }elseif(strpos($domain,'114.vnet.cn')!== false && preg_match('/kw=([^&]*)/i',$path,$regs)){ $searchengine = 'CT114'; $keywords = urldecode($regs[1]); // ct114 }elseif(strpos($domain,'iask.com')!==false && preg_match('/k=([^&]*)/i',$path,$regs)){ $searchengine = 'IASK'; $keywords = urldecode($regs[1]); // iask }elseif(strpos($domain,'soso.com')!==false && preg_match('/w=([^&]*)/i',$path,$regs)){ $searchengine = 'SOSO'; $keywords = urldecode($regs[1]); // soso }elseif(strpos($domain, 'sogou.com')!==false && preg_match('/query=([^&]*)/i',$path,$regs)){ $searchengine = 'SOGOU'; $keywords = urldecode($regs[1]); // sogou }elseif(strpos($domain,'so.163.com')!==false && preg_match('/q=([^&]*)/i',$path,$regs)){ $searchengine = 'NETEASE'; $keywords = urldecode($regs[1]); // netease }elseif(strpos($domain,'yodao.com')!== false && preg_match('/q=([^&]*)/i',$path,$regs)){ $searchengine = 'YODAO'; $keywords = urldecode($regs[1]); // yodao }elseif(strpos($domain,'zhongsou.com')!==false && preg_match('/word=([^&]*)/i',$path,$regs)){ $searchengine = 'ZHONGSOU'; $keywords = urldecode($regs[1]); // zhongsou }elseif(strpos($domain,'search.tom.com')!==false && preg_match('/w=([^&]*)/i',$path,$regs)){ $searchengine = 'TOM'; $keywords = urldecode($regs[1]); // tom }elseif(strpos($domain,'live.com')!==false && preg_match('/q=([^&]*)/i',$path,$regs)){ $searchengine = 'MSLIVE'; $keywords = urldecode($regs[1]); // MSLIVE }elseif(strpos($domain, 'tw.search.yahoo.com')!==false && preg_match('/p=([^&]*)/i',$path,$regs)){ $searchengine = 'YAHOO *'; $keywords = urldecode($regs[1]); // yahoo * }elseif(strpos($domain,'cn.yahoo.')!==false && preg_match('/p=([^&]*)/i',$path,$regs)){ $searchengine = 'YAHOO CHINA'; $keywords = urldecode($regs[1]); // yahoo china }elseif(strpos($domain,'yahoo.')!==false && preg_match('/p=([^&]*)/i',$path,$regs)){ $searchengine = 'YAHOO'; $keywords = urldecode($regs[1]); // yahoo }elseif(strpos($domain,'msn.com.tw')!==false && preg_match('/q=([^&]*)/i',$path,$regs)){ $searchengine = 'MSN *'; $keywords = urldecode($regs[1]); // msn * }elseif(strpos($domain,'msn.com.cn')!==false && preg_match('/q=([^&]*)/i',$path,$regs)){ $searchengine = 'MSN CHINA'; $keywords = urldecode($regs[1]); // msn china }elseif(strpos($domain,'msn.com')!==false && preg_match('/q=([^&]*)/i',$path,$regs)){ $searchengine = 'MSN'; $keywords = urldecode($regs[1]); // msn } return $keywords; }