本文目錄一覽:
- 1、如何 用php抓取google關鍵詞排名
- 2、php如何記錄用戶搜索過的關鍵詞的
- 3、誰能發(fā)個php獲取關鍵詞的百度排名的代碼
- 4、SEO里頭關鍵詞統(tǒng)計監(jiān)控表,是什么?怎么做?
- 5、多多情報通怎么使用???怎么查詢關鍵詞排名
如何 用php抓取google關鍵詞排名
1.說下思路,利用PHP的curl函數(shù)儲存cookie,google搜索頁面是無法用file_get_connents打開的,必須要完全模擬瀏覽器才行,百度就不同了,直接用file_get_conntens抓取頁面,然后用正則處理下就行了。
2.[code]?php
header("Content-Type:text/html;charset=utf-8");
functionggsearch($url_s,$keyword,$page=1){
$enKeyword=urlencode($keyword);
$rsState=false;
$page_num=($page-1)*10;
if($page=10){
$interface="eth0:".rand(1,4);//避免GG封IP
$cookie_file=dirname(__FILE__)."/temp/google.txt";//存儲cookie值
$url=";hl=enprmd=imvnsei=JPnJTvLFI8HlggeXwbRlstart=$page_numsa=N";
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
//curl_setopt($ch,CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);//獲取瀏覽器類型
curl_setopt($ch,CURLOPT_USERAGENT,"Mozilla/5.0(Windows;U;WindowsNT6.1;en-US;rv:1.9.1.2)Gecko/20090729Firefox/3.5.2GTB5");
curl_setopt($ch,CURLOPT_INTERFACE,"$interface");//指定訪問IP地址
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch,CURLOPT_COOKIEJAR,$cookie_file);
$contents=curl_exec($ch);
curl_close($ch);
$match="!div\s*id=\"search\"(.*)/div\s+\!--z--!";
preg_match_all("$match","$contents",$line);
while(list($k,$v)=each($line[0])){
preg_match_all("!h3\s+class=\"r\"a[^]+(.*?)/a!",$v,$title);
$num=count($title[1]);
for($i=0;$i$num;$i++){
if(strstr($title[0][$i],$url_s)){
$rsState=true;
$j=$i+1;
$sum=$j+(($page)*10-10);
//echo$contents;
echo"關鍵字".$keyword."br"."排名:".'fontcolor="red"size="20"style=""'.$sum.'/font'."####"."第".'fontcolor="#00FFFF"size="18"style=""'.$page.'/font'."頁"."第".'fontcolor="#8000FF"size="15"style=""'.$j.'/font'."名".$title[0][$i]."br";
echo"ahref='".$url."'"."點擊搜索結果"."/a"."br";
echo"hr";
break;
}
}
}
unset($contents);
if($rsState===false){
ggsearch($url_s,$keyword,++$page);//找不到搜索頁面的繼續(xù)往下搜索
}
}else{
echo'關鍵字'.$keyword.'10頁之內(nèi)沒有該網(wǎng)站排名'.'br';
echo"hr";
}
}
if(!empty($_POST['submit'])){
$time=explode('',microtime());
$start=$time[0]+$time[1];
$more_key=trim($_POST['textarea']);
$url_s=trim($_POST['url']);
if(!empty($more_key)!empty($url_s)){
/*判斷輸入字符的規(guī)律*/
if(strstr($more_key,"\n")){
$exkey=explode("\n",$more_key);
}
if(strstr($more_key,"|")){
$exkey=explode("|",$more_key);
}
if(!strstr($more_key,"\n")!strstr($more_key,"|")){
$exkey=array($more_key);
}
/*判斷是否有xintu或者http://之類的東西*/
if(count(explode('.',$url_s))=2){
$url=ltrim($url_s,'');
$url='xintu.'.$url_s;
}
foreach($exkeyas$keyword){
//$keyword;
ggsearch($url_s,$keyword);
}
$endtime=explode('',microtime());
$end=$endtime[0]+$endtime[1];
echo'hr';
echo'程序運行時間:';
echo$end-$start;
//die();
}
}
?
!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN"""
htmlxmlns=""
head
title抓取排名/title
/head
body
formaction=""method="post"
span關鍵字:/spantextareaname="textarea"rows="20"cols="40"wrap="off"
格式例如:keyword1|keyword2|keyword3
或者:keyword1
keyword2
keyword3
/textarea
spanurl地址:/spaninputtype="text"name="url"
inputtype="submit"name="submit"value="搜索"
/form
/body
php如何記錄用戶搜索過的關鍵詞的
寫個函數(shù) 每次提交的時候,自動把關鍵詞放到數(shù)據(jù)庫里,如果數(shù)據(jù)庫里有這個關鍵詞,那就在搜索次數(shù)上+1
不過你要真這樣做 會有很多問題的,用戶不會僅僅搜索關鍵詞,肯定有很多不規(guī)則搜索的。
像ECSHOP DEDECMS 這些比較成型的PHP產(chǎn)品都是在后臺制定關鍵詞顯示出來,然后對僅有指定的關鍵詞進行排行
誰能發(fā)個php獲取關鍵詞的百度排名的代碼
?php
function s($keyword,$url,$page = 1){
static $px = 0;
$rsState = false;
$enKeyword = urlencode($keyword);
$firstRow = ($page - 1) * 10;
if($page 10){
die('10頁之內(nèi)沒有該網(wǎng)站排名..end');
}
$contents = file_get_contents(";pn=$firstRow");
preg_match_all('/table[^]*?class="result"[^]*[\s\S]*?\/table/i',$contents,$rs);
foreach($rs[0] as $k=$v){
$px++;
if(strstr($v,$url)){
$rsState = true;
preg_match_all('/h3[\s\S]*?(a[\s\S]*?\/a)/',$v,$rs_t);
echo '當前 "' . $url . '" 在百度關鍵字 "' . $keyword . '" 中的排名為:' . $px;
echo 'br';
echo '第' . $page . '頁;第' . ++$k . "個a target='_blank' href=';pn=$firstRow'進入百度/a";
echo 'br';
//PRINT_r($rs_t);die;
echo $rs_t[1][0];
//echo iconv('GBK','UTF-8//IGNORE',$rs_t[1][0]);
break;
}
}
unset($contents);
if($rsState === false){
s($keyword, $url,++$page);
}
}
if(isset($_POST['submit'])){
$time = explode(' ',microtime());
$start = $time[0] + $time[1];
$url = $_POST['url'];
if( count(explode('.',$url)) = 2){
$url = ltrim($url,'http://');
$url = 'xintu.' . $url;
}
s($_POST['keyword'],$url);
$endtime = explode(' ',microtime());
$end = $endtime[0] + $endtime[1];
echo 'hr';
echo '程序運行時間: ';
echo $end - $start;
die();
}
?
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""
html xmlns=""
head
meta http-equiv="Content-Type" content="text/html; charset=utf-8" /
title抓取排名/title
/head
body
form action="" method="post"
ul
li
span關鍵字:/spaninput type="text" name="keyword"
/li
li
spanurl地址:/spaninput type="text" name="url"
/li
li
input type="submit" name="submit" value="搜索"
/li
/ul
/form
/body
/html
SEO里頭關鍵詞統(tǒng)計監(jiān)控表,是什么?怎么做?
我公司的作法是:
就是把你網(wǎng)站關鍵詞 羅列出一個表格
用excel做表格,每一個關鍵詞,都記錄 百度排名,點擊ip,百度收錄等等相關的數(shù)據(jù),每天都要檢查
多多情報通怎么使用啊?怎么查詢關鍵詞排名
查拼多多排名使用多多情報通!可以查詢拼多多類目排名、店鋪排名、屬性排名,關鍵詞排名等等,查詢時間間隔分為:日、周、月、年,查詢幅度大,數(shù)據(jù)精確度高。
多多情報通查詢關鍵詞排名的方法:
1.請在瀏覽器網(wǎng)址欄輸入“ddcm。mobduos。com/register?code=CWUAPG_6”,登錄到多多情報通的商家管理后臺。
2.請輸入賬號密碼登錄,如果還沒注冊,請用手機號碼注冊。進入商家管理后臺后,如果是新注冊的朋友,請在右上角的“綁定新店鋪”輸入自己店鋪ID進行綁定。
3.把鼠標箭頭放到功能欄那里的“推廣”,然后點擊“天眼探測”,然后跳到這個功能的頁面。這時候需要輸入商品ID,我們可以輸入自己的商品ID,也可以輸入競品的ID,分析別人爆款的關鍵詞。
想要了解更多關于多多情報通的相關信息,推薦咨詢多多情報通。MobDuos是廣州匯睿網(wǎng)絡科技有限公司旗下的智能移動營銷服務平臺。一家社交電商數(shù)據(jù)SaaS服務商,為企業(yè)、品牌或個人商家提供數(shù)據(jù)資源服務。覆蓋拼多多、抖音、快手、跨境Shopee和微信小程序等主流電商平臺,提供數(shù)據(jù)運營決策服務。
掃描二維碼推送至手機訪問。
版權聲明:本文由信途科技轉載于網(wǎng)絡,如有侵權聯(lián)系站長刪除。