Java版PageRank及网站收录情况查询代码


在Google这个由10的100次方得名的站点中,各种评估网站的算法层出不穷,而PageRank即是其中之一。

Google的PageRank根据网站的外部链接和内部链接的数量和质量俩衡量网站的价值。PageRank背后的概念是,每个到页面的链接都是对该页面的一次投票,被链接的越多,就意味着被其他网站投票越多。这个就是所谓的“链接流行度”——衡量多少人愿意将他们的网站和你的网站挂钩。PageRank这个概念引自学术中一篇论文的被引述的频度——即被别人引述的次数越多,一般判断这篇论文的权威性就越高。

通常情况下讲,原创内容越多的站点,PageRank越容易提升,反之则相对比较困难,PageRank最大上限值为10。在Google的评估中,能上10的网站真可谓凤毛麟角,即使算上Google,能成就PageRank 10这“伟业”者,望眼环球也不足40家。一般来说,个人站点评估值4即办的不错,商业网站到6以上便算步入正轨了。

网上虽然有不少现成的查询器及源码,但是光用别人的毕竟不符合程序员风格,所以今天自己用Java重造轮子又写了个PageRank查询实现,捎带着把一些常用搜索引擎的网站链接及反向链接查询也加上了。

源码如下:


GooglePageRank.java
  1. packageorg.loon.test;
  2. importjava.io.IOException;
  3. importjava.util.Random;
  4. importjava.util.regex.Matcher;
  5. importjava.util.regex.Pattern;
  6. /**
  7. *Copyright2008
  8. *
  9. *LicensedundertheApacheLicense,Version2.0(the"License");youmaynot
  10. *usethisfileexceptincompliancewiththeLicense.Youmayobtainacopyof
  11. *theLicenseat
  12. *
  13. *http://www.apache.org/licenses/LICENSE-2.0
  14. *
  15. *Unlessrequiredbyapplicablelaworagreedtoinwriting,software
  16. *distributedundertheLicenseisdistributedonan"ASIS"BASIS,WITHOUT
  17. *WARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.Seethe
  18. *Licenseforthespecificlanguagegoverningpermissionsandlimitationsunder
  19. *theLicense.
  20. *
  21. *@projectloonframework
  22. *@authorchenpeng
  23. *@email:[email protected]
  24. *@version0.1
  25. */
  26. publicclassGooglePageRank{
  27. //googlepagerank服务器ip地址列表(最近google小气了很多,反复查询一个封ip)
  28. finalstaticString[]GoogleServiceIP=newString[]{"64.233.161.100",
  29. "64.233.161.101","64.233.183.91","64.233.189.44","66.102.1.103",
  30. "66.102.9.115","66.249.89.83","66.249.91.99","66.249.93.190"};
  31. //google用识别标记
  32. finalstaticprivateintGOOGLE_MAGIC=0xE6359A60;
  33. //ch数值混合器
  34. privateclassCHMix{
  35. inta;
  36. intb;
  37. intc;
  38. publicCHMix(){
  39. this(0,0,0);
  40. }
  41. publicCHMix(inta,intb,intc){
  42. this.a=a;
  43. this.b=b;
  44. this.c=c;
  45. }
  46. }
  47. /**
  48. *按google要求混合成ch数据
  49. *
  50. *@parammix
  51. */
  52. privatestaticvoidmix(finalCHMixmix){
  53. mix.a-=mix.b;
  54. mix.a-=mix.c;
  55. mix.a^=mix.c>>13;
  56. mix.b-=mix.c;
  57. mix.b-=mix.a;
  58. mix.b^=mix.a<<8;
  59. mix.c-=mix.a;
  60. mix.c-=mix.b;
  61. mix.c^=mix.b>>13;
  62. mix.a-=mix.b;
  63. mix.a-=mix.c;
  64. mix.a^=mix.c>>12;
  65. mix.b-=mix.c;
  66. mix.b-=mix.a;
  67. mix.b^=mix.a<<16;
  68. mix.c-=mix.a;
  69. mix.c-=mix.b;
  70. mix.c^=mix.b>>5;
  71. mix.a-=mix.b;
  72. mix.a-=mix.c;
  73. mix.a^=mix.c>>3;
  74. mix.b-=mix.c;
  75. mix.b-=mix.a;
  76. mix.b^=mix.a<<10;
  77. mix.c-=mix.a;
  78. mix.c-=mix.b;
  79. mix.c^=mix.b>>15;
  80. }
  81. /**
  82. *获得ch数值混合器
  83. *
  84. *@return
  85. */
  86. publicstaticCHMixgetInnerCHMix(){
  87. returnnewGooglePageRank().newCHMix();
  88. }
  89. /**
  90. *通过url获得googlech(google数据库针对页面的全球唯一标识)
  91. *
  92. *@paramurl
  93. *@return
  94. */
  95. publicstaticStringGoogleCH(finalStringurl){
  96. //格式化为google要求的info:url模式
  97. StringnUrl=String.format("info:%s",newObject[]{url});
  98. //获得新url字符串格式
  99. char[]urls=nUrl.toCharArray();
  100. //获得新url长度
  101. intlength=urls.length;
  102. //获得一个ch数值混合器
  103. CHMixchMix=GooglePageRank.getInnerCHMix();
  104. //为c注入google识别标识
  105. chMix.c=GOOGLE_MAGIC;
  106. //为a、b项注入google要求的初始标识
  107. chMix.a=chMix.b=0x9E3779B9;
  108. intk=0;
  109. intlen=length;
  110. while(len>=12){
  111. chMix.a+=(int)(urls[k+0]+(urls[k+1]<<8)
  112. +(urls[k+2]<<16)+(urls[k+3]<<24));
  113. chMix.b+=(int)(urls[k+4]+(urls[k+5]<<8)
  114. +(urls[k+6]<<16)+(urls[k+7]<<24));
  115. chMix.c+=(int)(urls[k+8]+(urls[k+9]<<8)
  116. +(urls[k+10]<<16)+(urls[k+11]<<24));
  117. //获得混合运算后的数据
  118. GooglePageRank.mix(chMix);
  119. k+=12;
  120. len-=12;
  121. }
  122. chMix.c+=length;
  123. //产生googlech的11位标识
  124. switch(len){
  125. case11:
  126. chMix.c+=(int)(urls[k+10]<<24);
  127. case10:
  128. chMix.c+=(int)(urls[k+9]<<16);
  129. case9:
  130. chMix.c+=(int)(urls[k+8]<<8);
  131. case8:
  132. chMix.b+=(int)(urls[k+7]<<24);
  133. case7:
  134. chMix.b+=(int)(urls[k+6]<<16);
  135. case6:
  136. chMix.b+=(int)(urls[k+5]<<8);
  137. case5:
  138. chMix.b+=(int)(urls[k+4]);
  139. case4:
  140. chMix.a+=(int)(urls[k+3]<<24);
  141. case3:
  142. chMix.a+=(int)(urls[k+2]<<16);
  143. case2:
  144. chMix.a+=(int)(urls[k+1]<<8);
  145. case1:
  146. chMix.a+=(int)(urls[k+0]);
  147. break;
  148. default:
  149. break;
  150. }
  151. //获得混合运算后的数据
  152. GooglePageRank.mix(chMix);
  153. //获得未修订的CH
  154. Stringtch=String.valueOf(chMix.c);
  155. //矫正差值后反馈正确CH
  156. returnString
  157. .format("6%s",newObject[]{tch.length()<10?("-"+tch)
  158. .intern():tch});
  159. }
  160. /**
  161. *正则匹配pagerank结果
  162. *
  163. *@paramvalue
  164. *@return
  165. */
  166. privatestaticStringMatchRank(finalStringvalue){
  167. Patternpattern=Pattern.compile("Rank_1:[0-9]:([0-9]+)");
  168. Matchermatcher=pattern.matcher(value);
  169. if(matcher.find()){
  170. returnmatcher.group(1);
  171. }
  172. return"0";
  173. }
  174. /**
  175. *获得指定页面的googlepagerank值
  176. *
  177. *@paramurl
  178. *@return
  179. */
  180. publicstaticStringGooglePR(finalStringurl){
  181. Stringrip=GoogleServiceIP[newRandom()
  182. .nextInt(GoogleServiceIP.length)];
  183. returnGooglePR(url,rip);
  184. }
  185. /**
  186. *以指定的google服务器获得指定页面的googlepagerank值
  187. *
  188. *@paramurl
  189. *@paramip
  190. *@return
  191. */
  192. publicstaticStringGooglePR(finalStringurl,finalStringip){
  193. //产生查询用唯一标识
  194. Stringchecksum=GoogleCH(url);
  195. //产生查询用url
  196. StringqueryUrl=String
  197. .format(
  198. "http://%s/search?client=navclient-auto&ch=%s&features=Rank&q=info:%s",
  199. newObject[]{ip,checksum,url});
  200. Stringresponse;
  201. try{
  202. response=SimpleWebClient.getRequestHttp(queryUrl);
  203. }catch(IOExceptione){
  204. response="";
  205. }
  206. if(response.length()==0){
  207. return"0";
  208. }else{
  209. returnGooglePageRank.MatchRank(response);
  210. }
  211. }
  212. }

SimpleWebClient.java


  1. packageorg.loon.test;
  2. importjava.io.BufferedInputStream;
  3. importjava.io.ByteArrayOutputStream;
  4. importjava.io.IOException;
  5. importjava.io.InputStream;
  6. importjava.io.InputStreamReader;
  7. importjava.io.OutputStreamWriter;
  8. importjava.net.HttpURLConnection;
  9. importjava.net.URL;
  10. importjava.util.HashMap;
  11. importjava.util.Iterator;
  12. importjava.util.Map;
  13. importjava.util.Set;
  14. importjava.util.Map.Entry;
  15. importsun.misc.BASE64Encoder;
  16. /**
  17. *Copyright2008
  18. *
  19. *LicensedundertheApacheLicense,Version2.0(the"License");youmaynot
  20. *usethisfileexceptincompliancewiththeLicense.Youmayobtainacopyof
  21. *theLicenseat
  22. *
  23. *http://www.apache.org/licenses/LICENSE-2.0
  24. *
  25. *Unlessrequiredbyapplicablelaworagreedtoinwriting,software
  26. *distributedundertheLicenseisdistributedonan"ASIS"BASIS,WITHOUT
  27. *WARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.Seethe
  28. *Licenseforthespecificlanguagegoverningpermissionsandlimitationsunder
  29. *theLicense.
  30. *
  31. *@projectloonframework
  32. *@authorchenpeng
  33. *@email:[email protected]
  34. *@version0.1
  35. */
  36. publicclassSimpleWebClient{
  37. /**
  38. *向指定url发送请求并获得响应数据
  39. *
  40. *@paramurlString
  41. *@return
  42. *@throwsIOException
  43. */
  44. publicstaticStringgetRequestHttp(StringurlString)throwsIOException{
  45. returngetRequestHttp(urlString,"utf-8");
  46. }
  47. /**
  48. *向指定url发送请求并获得响应数据
  49. *
  50. *@paramurlString
  51. *@paramencoding
  52. *@return
  53. *@throwsIOException
  54. */
  55. publicstaticStringgetRequestHttp(StringurlString,Stringencoding)
  56. throwsIOException{
  57. returngetRequestHttp(urlString,encoding,null,5000);
  58. }
  59. /**
  60. *向指定url发送请求并获得响应数据
  61. *
  62. *@paramurlString
  63. *@paramencoding
  64. *@paramparameter
  65. *@return
  66. *@throwsIOException
  67. */
  68. publicstaticStringgetRequestHttp(finalStringurlString,
  69. finalStringencoding,finalMapparameter,finalinttimeout)
  70. throwsIOException{
  71. StringnURL=(urlString.startsWith("http://")||urlString
  72. .startsWith("https://"))?urlString:("http:"+urlString)
  73. .intern();
  74. Stringuser=null;
  75. Stringpassword=null;
  76. Stringmethod="GET";
  77. Stringpost=null;
  78. Stringdigest=null;
  79. StringresponseContent="ERROR";
  80. booleanfoundRedirect=false;
  81. Mapheaders=newHashMap();
  82. if(parameter!=null){
  83. SetentrySet=parameter.entrySet();
  84. for(Iteratorit=entrySet.iterator();it.hasNext();){
  85. Entryheader=(Entry)it.next();
  86. Stringkey=(String)header.getKey();
  87. Stringvalue=(String)header.getValue();
  88. if("user".equals(key)){
  89. user=value;
  90. }elseif("pass".equals(key)){
  91. password=value;
  92. }elseif("method".equals(key)){
  93. method=value;
  94. }elseif("post".equals(key)){
  95. post=value;
  96. }else{
  97. headers.put(key,value);
  98. }
  99. }
  100. }
  101. URLurl=newURL(nURL);
  102. if(user!=null&&password!=null){
  103. BASE64Encoderbase64=newBASE64Encoder();
  104. digest="Basic"
  105. +base64.encode((user+":"+password).getBytes());
  106. }
  107. do{
  108. HttpURLConnectionurlConnection=(HttpURLConnection)url
  109. .openConnection();
  110. //添加访问授权
  111. if(digest!=null){
  112. urlConnection.setRequestProperty("Authorization",digest);
  113. }
  114. urlConnection.setDoOutput(true);
  115. urlConnection.setDoInput(true);
  116. urlConnection.setUseCaches(false);
  117. urlConnection.setInstanceFollowRedirects(false);
  118. urlConnection.setRequestMethod(method);
  119. if(timeout>0){
  120. urlConnection.setConnectTimeout(timeout);
  121. }
  122. //模拟http头文件
  123. urlConnection.setRequestProperty("User-Agent","Mozilla/4.0(compatible;MSIE7.0;)");
  124. urlConnection.setRequestProperty("Accept","image/gif,image/x-xbitmap,image/jpeg,image/pjpeg,application/x-shockwave-flash,application/msword,application/vnd.ms-excel,application/vnd.ms-powerpoint,*/*");
  125. //追加http头文件
  126. SetheadersSet=headers.entrySet();
  127. for(Iteratorit=headersSet.iterator();it.hasNext();){
  128. Entryentry=(Entry)it.next();
  129. urlConnection.setRequestProperty((String)entry.getKey(),
  130. (String)entry.getValue());
  131. }
  132. if(post!=null){
  133. OutputStreamWriteroutRemote=newOutputStreamWriter(
  134. urlConnection.getOutputStream());
  135. outRemote.write(post);
  136. outRemote.flush();
  137. }
  138. //获得响应状态
  139. intresponseCode=urlConnection.getResponseCode();
  140. //获得返回的数据长度
  141. intresponseLength=urlConnection.getContentLength();
  142. if(responseCode==302){
  143. //重定向
  144. Stringlocation=urlConnection.getHeaderField("Location");
  145. url=newURL(location);
  146. foundRedirect=true;
  147. }else{
  148. BufferedInputStreamin;
  149. if(responseCode==200||responseCode==201){
  150. in=newBufferedInputStream(urlConnection.getInputStream());
  151. }else{
  152. in=newBufferedInputStream(urlConnection.getErrorStream());
  153. }
  154. intsize=responseLength==-1?4096:responseLength;
  155. if(encoding!=null){
  156. responseContent=SimpleWebClient.read(in,size,encoding);
  157. }else{
  158. ByteArrayOutputStreamout=newByteArrayOutputStream();
  159. byte[]bytes=newbyte[size];
  160. intread;
  161. while((read=in.read(bytes))>=0){
  162. out.write(bytes,0,read);
  163. }
  164. responseContent=newString(out.toByteArray());
  165. in.close();
  166. out.close();
  167. }
  168. foundRedirect=false;
  169. }
  170. //如果重定向则继续
  171. }while(foundRedirect);
  172. returnresponseContent;
  173. }
  174. /**
  175. *转化InputStream为String
  176. *
  177. *@paramin
  178. *@paramsize
  179. *@return
  180. *@throwsIOException
  181. */
  182. privatestaticStringread(finalInputStreamin,finalintsize,
  183. finalStringencoding)throwsIOException{
  184. StringBuildersbr=newStringBuilder();
  185. intnSize=size;
  186. if(nSize==0){
  187. nSize=1;
  188. }
  189. char[]buffer=newchar[nSize];
  190. intoffset=0;
  191. InputStreamReaderisr=newInputStreamReader(in,encoding);
  192. while((offset=isr.read(buffer))!=-1){
  193. sbr.append(buffer,0,offset);
  194. }
  195. in.close();
  196. isr.close();
  197. returnsbr.toString();
  198. }
  199. }

WebAppraise.java
  1. packageorg.loon.test;
  2. importjava.io.IOException;
  3. /**
  4. *Copyright2008
  5. *
  6. *LicensedundertheApacheLicense,Version2.0(the"License");youmaynot
  7. *usethisfileexceptincompliancewiththeLicense.Youmayobtainacopyof
  8. *theLicenseat
  9. *
  10. *http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. *Unlessrequiredbyapplicablelaworagreedtoinwriting,software
  13. *distributedundertheLicenseisdistributedonan"ASIS"BASIS,WITHOUT
  14. *WARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.Seethe
  15. *Licenseforthespecificlanguagegoverningpermissionsandlimitationsunder
  16. *theLicense.
  17. *
  18. *@projectloonframework
  19. *@authorchenpeng
  20. *@email:[email protected]
  21. *@version0.1
  22. */
  23. publicclassWebAppraise{
  24. privateStringgoogleSum;
  25. privateStringbaiduSum;
  26. privateStringmsnSum;
  27. privateStringaltaVistaSum;
  28. privateStringallTheWebSum;
  29. privateStringyahooSum;
  30. privateStringtestURL;
  31. publicWebAppraise(finalStringurl){
  32. if(url!=null&&!"".equals(url)){
  33. this.testURL=url.trim();
  34. if(this.testURL.startsWith("http://")){
  35. this.testURL=this.testURL.substring(7);
  36. }
  37. if(this.testURL.startsWith("https://")){
  38. this.testURL=this.testURL.substring(8);
  39. }
  40. }else{
  41. thrownewRuntimeException("urlisNULL!");
  42. }
  43. }
  44. /**
  45. *分析指定链接结果,并返回整型数值
  46. *
  47. *@paramsearchURL
  48. *@paramanchor
  49. *@paramtrail
  50. *@return
  51. */
  52. privatestaticintgetLinks(finalStringsearchURL,finalStringanchor,
  53. finalStringtrail){
  54. intcount=0;
  55. StringserverResponse;
  56. try{
  57. //我国特色……
  58. if(searchURL.startsWith("http://www.baidu.com")){
  59. //永不离休的gb2312同志(-_-||)
  60. serverResponse=SimpleWebClient.getRequestHttp(searchURL,
  61. "gb2312");
  62. }else{
  63. serverResponse=SimpleWebClient.getRequestHttp(searchURL);
  64. }
  65. }catch(IOExceptione){
  66. serverResponse=e.getMessage();
  67. }
  68. intpos=serverResponse.indexOf(anchor);
  69. if(pos>1){
  70. serverResponse=serverResponse.substring(pos+anchor.length());
  71. pos=serverResponse.indexOf(trail);
  72. Stringvalue=serverResponse.substring(0,pos).trim();
  73. value=value.replace(",","");
  74. value=value.replace(".","");
  75. count=Integer.parseInt(value);
  76. }
  77. returncount;
  78. }
  79. publicStringgetAllTheWebSite(){
  80. returngetAllTheWebSite(false);
  81. }
  82. publicStringgetAllTheWebSite(booleanisDomain){
  83. try{
  84. StringallTheWeb;
  85. if(isDomain){
  86. allTheWeb="http://www.alltheweb.com/search?cat=web&cs=utf8&rys=0&itag=crv&_sb_lang=any&q=linkdomain%3A"
  87. +this.testURL;
  88. }else{
  89. allTheWeb="http://www.alltheweb.com/search?cat=web&cs=utf-8&q=link%3Ahttp%3A%2F%2F"
  90. +this.testURL+"&_sb_lang=any";
  91. }
  92. allTheWebSum=""
  93. +getLinks(allTheWeb,"<spanclass=/"ofSoMany/">",
  94. "</span>");
  95. }catch(Exceptionex){
  96. allTheWebSum=ex.getMessage();
  97. }
  98. returnallTheWebSum;
  99. }
  100. publicStringgetAltaVistaSite(){
  101. returngetAltaVistaSite(false);
  102. }
  103. publicStringgetAltaVistaSite(booleanisDomain){
  104. try{
  105. StringaltaVista;
  106. if(isDomain){
  107. altaVista="http://www.altavista.com/web/results?itag=ody&q=link%3A"
  108. +this.testURL+"&kgs=0&kls=0";
  109. }else{
  110. altaVista="http://www.altavista.com/web/results?itag=ody&kgs=0&kls=0&q=site%3A"
  111. +this.testURL;
  112. }
  113. altaVistaSum=""+getLinks(altaVista,"AltaVistafound","");
  114. }catch(Exceptionex){
  115. altaVistaSum=ex.getMessage();
  116. }
  117. returnaltaVistaSum;
  118. }
  119. publicStringgetGooglePR(){
  120. returnGooglePageRank.GooglePR(this.testURL);
  121. }
  122. publicStringgetGoogleSite(){
  123. returngetGoogleSite(false);
  124. }
  125. publicStringgetGoogleSite(finalbooleanisDomian){
  126. try{
  127. Stringgoogle;
  128. //反向链接
  129. if(isDomian){
  130. google="http://www.google.com/search?hl=en&q=link%3A"
  131. +this.testURL;
  132. }else{
  133. google="http://www.google.com/search?hl=en&q=site%3A"
  134. +this.testURL+"&btnG=Google+Search&aq=f&oq=";
  135. }
  136. googleSum=""+getLinks(google,"about<b>","</b>");
  137. }catch(Exceptionex){
  138. googleSum=ex.getMessage();
  139. }
  140. returngoogleSum;
  141. }
  142. publicStringgetBaiduSite(){
  143. returngetBaiduSite(false);
  144. }
  145. publicStringgetBaiduSite(finalbooleanisDomian){
  146. try{
  147. Stringbaidu;
  148. if(isDomian){
  149. baidu="http://www.baidu.com/s?wd=domain%3A"+this.testURL
  150. +"&cl=3";
  151. }else{
  152. baidu="http://www.baidu.com/s?wd=site%3A"+this.testURL;
  153. }
  154. baiduSum=""+getLinks(baidu,"找到相关网页","篇");
  155. }catch(Exceptionex){
  156. Stringbaidu;
  157. if(isDomian){
  158. baidu="http://www.baidu.com/s?wd=domain%3A"+this.testURL
  159. +"&cl=3";
  160. }else{
  161. baidu="http://www.baidu.com/s?wd=site%3A"+this.testURL;
  162. }
  163. baiduSum=""+getLinks(baidu,"找到相关网页约","篇");
  164. }
  165. returnbaiduSum;
  166. }
  167. publicStringgetYahooSite(){
  168. returngetYahooSite(false);
  169. }
  170. publicStringgetYahooSite(finalbooleanisDomian){
  171. try{
  172. Stringyahoo;
  173. if(isDomian){
  174. yahoo="http://sitemap.cn.yahoo.com/search?p="+this.testURL
  175. +"&bwm=i";
  176. yahooSum=""+getLinks(yahoo,"<strong>","</strong>");
  177. }else{
  178. yahoo="http://www.yahoo.cn/s?p=site%3A"+this.testURL
  179. +"&pid=hp&v=web";
  180. yahooSum=""+getLinks(yahoo,"找到相关网页约","条");
  181. }
  182. }catch(Exceptionex){
  183. yahooSum=ex.getMessage();
  184. }
  185. returnyahooSum;
  186. }
  187. publicStringgetMsnSite(){
  188. returngetMsnSite(false);
  189. }
  190. publicStringgetMsnSite(booleanisDomain){
  191. try{
  192. Stringmsn;
  193. if(isDomain){
  194. msn="http://cnweb.search.live.com/results.aspx?q=link%3A"
  195. +this.testURL+"&mkt=zh-cn&scope=&FORM=LIVSO";
  196. }else{
  197. msn="http://cnweb.search.live.com/results.aspx?q=site%3A"
  198. +this.testURL+"&go=&form=QBRE";
  199. }
  200. msnSum=""+getLinks(msn,"共","条搜索结果");
  201. }catch(Exceptionex){
  202. msnSum=ex.getMessage();
  203. }
  204. returnmsnSum;
  205. }
  206. publicStringgetTestURL(){
  207. returntestURL;
  208. }
  209. }

Test.java
  1. packageorg.loon.test;
  2. /**
  3. *Copyright2008
  4. *
  5. *LicensedundertheApacheLicense,Version2.0(the"License");youmaynot
  6. *usethisfileexceptincompliancewiththeLicense.Youmayobtainacopyof
  7. *theLicenseat
  8. *
  9. *http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. *Unlessrequiredbyapplicablelaworagreedtoinwriting,software
  12. *distributedundertheLicenseisdistributedonan"ASIS"BASIS,WITHOUT
  13. *WARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.Seethe
  14. *Licenseforthespecificlanguagegoverningpermissionsandlimitationsunder
  15. *theLicense.
  16. *
  17. *@projectloonframework
  18. *@authorchenpeng
  19. *@email:[email protected]
  20. *@version0.1
  21. */
  22. publicclassTest{
  23. publicstaticvoidmain(String[]args){
  24. WebAppraiseappraise=newWebAppraise("http://blog.csdn.net/cping1982");
  25. System.out.println("GooglePagerRank值:"+appraise.getGooglePR());
  26. System.out.println("google收录:"+appraise.getGoogleSite());
  27. System.out.println("google反向收录:"+appraise.getGoogleSite(true));
  28. System.out.println("yahoo收录:"+appraise.getYahooSite());
  29. System.out.println("yahoo反向收录:"+appraise.getYahooSite(true));
  30. System.out.println("baidu收录:"+appraise.getBaiduSite());
  31. System.out.println("baidu反向收录:"+appraise.getBaiduSite(true));
  32. System.out.println("msn收录:"+appraise.getMsnSite());
  33. System.out.println("msn反向收录:"+appraise.getMsnSite(true));
  34. System.out.println("AllTheWeb收录:"+appraise.getAllTheWebSite());
  35. System.out.println("AllTheWeb反向收录:"+appraise.getAllTheWebSite(true));
  36. System.out.println("AltaVista收录:"+appraise.getAltaVistaSite());
  37. System.out.println("AltaVista反向收录:"+appraise.getAltaVistaSite(true));
  38. }
  39. }

检测 http://blog.csdn.net/cping1982运行结果如下图:

Java版PageRank及网站收录情况查询代码


源码下载地址:http://download.csdn.net/source/929348

你可能感兴趣的:(pagerank)