天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

Asp.Net、asp實現的搜索引擎網址收錄檢查程序

使用ASP.NET或者ASP檢查某個url地址,某篇文章是否被搜索引擎,如百度,谷歌,搜狗收錄。

實現原理:直接搜索你那篇文章的url地址(不帶協議,但上協議也行,代碼會自動去掉協議內容),如果被索引會返回搜索結果,否則會提示找不到信息。

ASP.NET檢查百度,谷歌,搜狗搜索引擎是否收錄文章網址源代碼:

using System;using System.NET;using System.Text;using System.IO;using System.Web;public class SearchEngineIndex{  public static string[] urls = { //搜索引擎檢查地址      "http://www.baidu.com/s?ie=utf-8&wd=",//百度索引url檢查地址      "https://www.google.com.hk/search?q=",//谷歌索引url檢查地址      "http://www.sogou.com/web?ie=utf8&query="http://搜狗索引url檢查地址    }    , noFindKeyword = { "抱歉,沒有找到與", "找不到和您的查詢", "未收錄?" };//搜索引擎未索引url地址時的關鍵字  /// <summary>  /// 獲取響應的編碼  /// </summary>  /// <param name="contenttype"></param>  /// <returns></returns>  private static Encoding GetEncoding(string contenttype)  {    if (!string.IsNullOrEmpty(contenttype))    {      contenttype = contenttype.ToLower();      if (contenttype.IndexOf("gb2312") != -1 || contenttype.IndexOf("gbk") != -1) return Encoding.GetEncoding(936);      if (contenttype.IndexOf("big5") != -1) return Encoding.GetEncoding(950);    }    return Encoding.UTF8;  }  /// <summary>  /// 使用HttpWebRequest對象,自動識別字符集  /// </summary>  /// <param name="url"></param>  /// <param name="addUseragent">是否添加UserAgent,采集其他網站時防止被攔截</param>  /// <returns></returns>  public static string GetHtml(string url, bool addUseragent)  {    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);    if (addUseragent) request.UserAgent = "Googlebot|Feedfetcher-Google|Baiduspider";    string html = null;    try    {      HttpWebResponse response = (HttpWebResponse)request.GetResponse();      StreamReader srd = new StreamReader(response.GetResponseStream(), GetEncoding(response.ContentType));      html = srd.ReadToEnd();      srd.Close();      response.Close();    }    catch { }    return html;  }  /// <summary>  /// 檢查某個url是否被搜索引擎索引  /// </summary>  /// <param name="url">url地址</param>  /// <param name="engin">0:百度 1:谷歌 2:搜狗,其他搜索引擎如bing和360直接查網址顯示的結果不是直接得到網址的,有些出入,不做檢查</param>  /// <returns></returns>  public static bool CheckIndex(string url, int engin)  {    if (string.IsNullOrEmpty(url)) return false;    if (engin < 0 || engin > 2) engin = 0;    url = urls[engin] + HttpUtility.UrlEncode(url.ToLower().Replace("http://", "").Replace("https://", ""));    bool r = true;    string html = GetHtml(url, true);    if (html == null || html.IndexOf(noFindKeyword[engin]) != -1) r = false;    return r;  }}//調用方法示例    SearchEngineIndex.CheckIndex("www.jb51.NET/article/20101014/2902.ASPx", 0);//檢查百度索引    SearchEngineIndex.CheckIndex("www.jb51.NET/article/20101014/2902.ASPx", 1);//檢查谷歌索引    SearchEngineIndex.CheckIndex("www.jb51.NET/article/20101014/2902.ASPx", 2);//檢查搜狗索引

ASP檢查百度,谷歌,搜狗搜索引擎是否收錄文章網址源代碼:

<%class SearchEnginIndex dim urls,noFindKeyword private sub Class_Initialize  '百度,谷歌,搜狗url地址索引查詢地址  urls=array("http://www.baidu.com/s?ie=utf-8&wd=","https://www.google.com.hk/search?q=","http://www.sogou.com/web?ie=utf8&query=")  '搜索引擎未索引url地址時的關鍵字  NoFindKeyword=array("抱歉,沒有找到與", "找不到和您的查詢", "未收錄?") End sub private function GetEncoding(contenttype)  contenttype=lcase(contenttype)  if instr(contenttype,"gb2312")<>0 and instr(contenttype,"gbk")<>0 then   GetEncoding="gb2312"  elseif instr(contenttype,"big5")<>0 then   GetEncoding="big5"  else   GetEncoding="utf-8"  end if end function private function BinToString(bin,encoding)'將2進制流數據依據編碼轉為對應的字符串內容  dim obj  set obj=Server.CreateObject("Adodb.Stream")  obj.Type=1:obj.Mode=3:obj.Open  obj.Write bin  obj.Position=0:obj.Type=2:obj.Charset=encoding  BinToString=obj.ReadText  obj.Close:set obj=nothing end function public function GetHtml(url)  dim xhr  set xhr=server.CreateObject("microsoft.xmlhttp")  xhr.open "get",url,false  xhr.send  encoding=GetEncoding(xhr.getResponseHeader("content-type"))  response.CharSet=encoding  GetHtml=BinToString(xhr.responsebody,encoding)  set xhr=nothing end function public function CheckIndex(url,engin)  if len(url)=0 then exit function  if engin<0 or engin>2 then engin=1  url=urls(engin)&server.URLEncode(url)  dim html  html=GetHtml(url)  CheckIndex=instr(html,NoFindKeyword(engin))=0 End functionend Classset sei=new SearchEnginIndexresponse.Write sei.CheckIndex("www.jb51.NET/article/20101014/2902.ASPx",0)'百度索引response.Write sei.CheckIndex("www.jb51.NET/article/20101014/2902.ASPx",1)'谷歌索引response.Write sei.CheckIndex("www.jb51.NET/article/20101014/2902.ASPx",2)'搜狗索引set sei=nothing %>

AspNet技術Asp.Net、asp實現的搜索引擎網址收錄檢查程序,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 入禽太深免费观看 | 亚洲1卡二卡3卡4卡新区在线 | 火影忍者高清无码黄漫 | 国产精品成人不卡在线观看 | 国产在线高清视频无码不卡 | 亚洲一区自拍高清亚洲精品 | 亚洲精品视频免费 | 黑人阴茎插女人图片 | 啪啪啪社区 | 乳巨揉みま痴汉电车中文字幕动漫 | 美女诱点第6季 | 青柠在线视频 | 高h喷水荡肉爽文总攻 | 中文字幕免费视频精品一 | 美国色情三级欧美三级纸匠情挑 | 亚洲精品国产自在在线观看 | 亚洲精品伊人久久久久 | 无套内谢大学生A片 | 国产精品AV视频一二三区 | 亚洲 欧美 国产 在线 日韩 | 门鱼电影完整版免费版 | 都市妖奇谈有声 | 99亚洲精品自拍AV成人软件 | 精品国产露脸久久AV麻豆 | 黄色小说在线 | 暖暖的高清视频在线观看免费中文 | 91av电影在线观看 | mxgs-877痉挛媚药按摩 | 旧里番6080在线观看 | 欧美男同gay粗大又长 | 亚洲va在线va天堂XX xX | 亚洲视频免费在线观看 | 国产成人免费片在线观看 | 国产伦精品一区二区免费 | 蜜芽tv在线观看免费网站 | 99久久精品全部 | 激情内射亚洲一区二区三区爱妻 | 秋霞电影网午夜一级鲁丝片 | yellow在线中文| 国产一区二区三区国产精品 | 亚洲国产精品无码中文字满 |