日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
用java代碼挖掘長尾關(guān)鍵詞的實現(xiàn)方法

本篇內(nèi)容介紹了“用java代碼挖掘長尾關(guān)鍵詞的實現(xiàn)方法”的有關(guān)知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

為禹王臺等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計制作服務(wù),及禹王臺網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為成都網(wǎng)站設(shè)計、成都網(wǎng)站建設(shè)、禹王臺網(wǎng)站設(shè)計,以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!

長尾關(guān)鍵詞(Long Tail Keyword)是指網(wǎng)站上的非目標(biāo)關(guān)鍵詞但與目標(biāo)關(guān)鍵詞相關(guān)的也可以帶來搜索流量的組合型關(guān)鍵詞。對于做SEO的人來說,這個名字再也熟悉不過了,但是如何來挖掘長尾關(guān)鍵詞,對于沒有數(shù)據(jù)或者一定計算機知識的人來說,還是很有難度的。所以這里附上非常簡單的辦法,只要幾行代碼就能輕松搞定。

# -*- coding: utf-8 -*-
# flake8: noqa
__author__ = 'wukong'

import urllib
from urllib import urlencode

#配置您申請的appKey和openId
app_key="***"
open_id="***"

"""
request_url 請求地址
params 請求參數(shù)
method 請求方法

"""
def request_content(request_url,params,method):
    params = urlencode(params)
    
    if method and method.lower() =="get":
        f = urllib.urlopen("%s?%s" % (request_url, params))
    else:
        f = urllib.urlopen(request_url, params)
 
    content = f.read()
    print content

   
def main():

    domain="http://api.xiaocongjisuan.com/"
    servlet="data/longtailword/mining"
    method="get"
    request_url=domain+servlet
    
    #字典
    params ={}
    params["appKey"]=app_key
    params["openId"]=open_id
    
    #變動部分
    params["keyword"]="學(xué)前教育"
    params["upLimit"]=50
    params["minLen"]=30
    params["lSort"]="up"
    
    request_content(request_url,params,method)
    
if __name__ == '__main__':
    main()

當(dāng)然也可以用c#來實現(xiàn)

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        private static string appKey="yours";
        private static string openId = "yours";
       
        static string getResponseAsString(HttpWebResponse rsp, Encoding encoding)
        {
            System.IO.Stream stream = null;
            StreamReader reader = null;
            try
            {
                // 以字符流的方式讀取HTTP響應(yīng)
                stream = rsp.GetResponseStream();
                reader = new StreamReader(stream, encoding);
                return reader.ReadToEnd();
            }
            finally
            {
                // 釋放資源
                if (reader != null) reader.Close();
                if (stream != null) stream.Close();
                if (rsp != null) rsp.Close();
            }
        }

        /*
         * parameters 參數(shù)
         * encode 編碼
         */

        static string buildQuery(IDictionary parameters, string encode)
        {
            StringBuilder postData = new StringBuilder();
            bool hasParam = false;
            IEnumerator> dem = parameters.GetEnumerator();
            while (dem.MoveNext())
            {
                string name = dem.Current.Key;
                string value = dem.Current.Value.ToString(); ;
                // 忽略參數(shù)名或參數(shù)值為空的參數(shù)
                if (!string.IsNullOrEmpty(name))//&& !string.IsNullOrEmpty(value)
                {
                    if (hasParam)
                    {
                        postData.Append("&");
                    }
                    postData.Append(name);
                    postData.Append("=");
                    if (encode == "gb2312")
                    {
                        postData.Append(System.Web.HttpUtility.UrlEncode(value, Encoding.GetEncoding("gb2312")));
                    }
                    else if (encode == "utf8")
                    {
                        postData.Append(System.Web.HttpUtility.UrlEncode(value, Encoding.UTF8));
                    }
                    else
                    {
                        postData.Append(value);
                    }
                    hasParam = true;
                }
            }
            return postData.ToString();
        }


        /**
        *
        * @param url 請求地址
        * @param params 請求參數(shù)
        * @param method 請求方法
        * @return 請求結(jié)果
        * @throws Exception
        */
        static string requestContent(string url, IDictionary parameters, string method)
        {
            if (method.ToLower() == "post")
            {
                HttpWebRequest req = null;
                HttpWebResponse rsp = null;
                System.IO.Stream reqStream = null;
                try
                {
                    req = (HttpWebRequest)WebRequest.Create(url);
                    req.Method = method;
                    req.KeepAlive = false;
                    req.ProtocolVersion = HttpVersion.Version10;
                    req.Timeout = 5000;
                    req.ContentType = "application/x-www-form-urlencoded;charset=utf-8";
                    byte[] postData = Encoding.UTF8.GetBytes(buildQuery(parameters, "utf8"));
                    reqStream = req.GetRequestStream();
                    reqStream.Write(postData, 0, postData.Length);
                    rsp = (HttpWebResponse)req.GetResponse();
                    Encoding encoding = Encoding.GetEncoding(rsp.CharacterSet);
                    return getResponseAsString(rsp, encoding);
                }
                catch (Exception ex)
                {
                    return ex.Message;
                }
                finally
                {
                    if (reqStream != null) reqStream.Close();
                    if (rsp != null) rsp.Close();
                }
            }
            else
            {
                //創(chuàng)建請求
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url + "?" + buildQuery(parameters, "utf8"));

                //GET請求
                request.Method = "GET";
                request.ReadWriteTimeout = 5000;
                request.ContentType = "text/html;charset=UTF-8";
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream myResponseStream = response.GetResponseStream();
                StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));

                //返回內(nèi)容
                string retString = myStreamReader.ReadToEnd();
                return retString;
            }
        }

        static void Main(string[] args)
        {

            String domain = "http://api.xiaocongjisuan.com/";
            String servlet = "data/longtailword/mining";
            String method = "get";
            String url = domain + servlet;


            var parameters = new Dictionary();

            parameters.Add("appKey", appKey);
            parameters.Add("openId", openId);

            //變動部分
            parameters.Add("keyword", "學(xué)前教育");
            parameters.Add("upLimit", 50);
            parameters.Add("minLen", 30);
            parameters.Add("lSort", "up");

            string result = requestContent(url, parameters, method);
            Console.WriteLine(result);
            Console.Read();

        }

    }
}

其他的語言實現(xiàn)方式可以跳轉(zhuǎn)到長尾關(guān)鍵詞接口去查看,代碼上還是非常簡潔的,就也不再做過多解釋。

“用java代碼挖掘長尾關(guān)鍵詞的實現(xiàn)方法”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!


當(dāng)前名稱:用java代碼挖掘長尾關(guān)鍵詞的實現(xiàn)方法
當(dāng)前鏈接:http://www.dlmjj.cn/article/iijsjd.html