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

系统 1577 0

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

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

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

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

源码如下:


GooglePageRank.java
  1. package org.loon.test;
  2. import java.io.IOException;
  3. import java.util.Random;
  4. import java.util.regex.Matcher;
  5. import java.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:ceponline@yahoo.com.cn
  24. *@version0.1
  25. */
  26. public class GooglePageRank{
  27. //googlepagerank服务器ip地址列表(最近google小气了很多,反复查询一个封ip)
  28. final static String[]GoogleServiceIP= new String[]{ "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. final static private int GOOGLE_MAGIC= 0xE6359A60 ;
  33. //ch数值混合器
  34. private class CHMix{
  35. int a;
  36. int b;
  37. int c;
  38. public CHMix(){
  39. this ( 0 , 0 , 0 );
  40. }
  41. public CHMix( int a, int b, int c){
  42. this .a=a;
  43. this .b=b;
  44. this .c=c;
  45. }
  46. }
  47. /**
  48. *按google要求混合成ch数据
  49. *
  50. *@parammix
  51. */
  52. private static void mix( final CHMixmix){
  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. public static CHMixgetInnerCHMix(){
  87. return new GooglePageRank(). new CHMix();
  88. }
  89. /**
  90. *通过url获得googlech(google数据库针对页面的全球唯一标识)
  91. *
  92. *@paramurl
  93. *@return
  94. */
  95. public static StringGoogleCH( final Stringurl){
  96. //格式化为google要求的info:url模式
  97. StringnUrl=String.format( "info:%s" , new Object[]{url});
  98. //获得新url字符串格式
  99. char []urls=nUrl.toCharArray();
  100. //获得新url长度
  101. int length=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. int k= 0 ;
  109. int len=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. case 11 :
  126. chMix.c+=( int )(urls[k+ 10 ]<< 24 );
  127. case 10 :
  128. chMix.c+=( int )(urls[k+ 9 ]<< 16 );
  129. case 9 :
  130. chMix.c+=( int )(urls[k+ 8 ]<< 8 );
  131. case 8 :
  132. chMix.b+=( int )(urls[k+ 7 ]<< 24 );
  133. case 7 :
  134. chMix.b+=( int )(urls[k+ 6 ]<< 16 );
  135. case 6 :
  136. chMix.b+=( int )(urls[k+ 5 ]<< 8 );
  137. case 5 :
  138. chMix.b+=( int )(urls[k+ 4 ]);
  139. case 4 :
  140. chMix.a+=( int )(urls[k+ 3 ]<< 24 );
  141. case 3 :
  142. chMix.a+=( int )(urls[k+ 2 ]<< 16 );
  143. case 2 :
  144. chMix.a+=( int )(urls[k+ 1 ]<< 8 );
  145. case 1 :
  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. return String
  157. .format( "6%s" , new Object[]{tch.length()< 10 ?( "-" +tch)
  158. .intern():tch});
  159. }
  160. /**
  161. *正则匹配pagerank结果
  162. *
  163. *@paramvalue
  164. *@return
  165. */
  166. private static StringMatchRank( final Stringvalue){
  167. Patternpattern=Pattern.compile( "Rank_1:[0-9]:([0-9]+)" );
  168. Matchermatcher=pattern.matcher(value);
  169. if (matcher.find()){
  170. return matcher.group( 1 );
  171. }
  172. return "0" ;
  173. }
  174. /**
  175. *获得指定页面的googlepagerank值
  176. *
  177. *@paramurl
  178. *@return
  179. */
  180. public static StringGooglePR( final Stringurl){
  181. Stringrip=GoogleServiceIP[ new Random()
  182. .nextInt(GoogleServiceIP.length)];
  183. return GooglePR(url,rip);
  184. }
  185. /**
  186. *以指定的google服务器获得指定页面的googlepagerank值
  187. *
  188. *@paramurl
  189. *@paramip
  190. *@return
  191. */
  192. public static StringGooglePR( final Stringurl, final Stringip){
  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. new Object[]{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. return GooglePageRank.MatchRank(response);
  210. }
  211. }
  212. }

SimpleWebClient.java


  1. package org.loon.test;
  2. import java.io.BufferedInputStream;
  3. import java.io.ByteArrayOutputStream;
  4. import java.io.IOException;
  5. import java.io.InputStream;
  6. import java.io.InputStreamReader;
  7. import java.io.OutputStreamWriter;
  8. import java.net.HttpURLConnection;
  9. import java.net.URL;
  10. import java.util.HashMap;
  11. import java.util.Iterator;
  12. import java.util.Map;
  13. import java.util.Set;
  14. import java.util.Map.Entry;
  15. import sun.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:ceponline@yahoo.com.cn
  34. *@version0.1
  35. */
  36. public class SimpleWebClient{
  37. /**
  38. *向指定url发送请求并获得响应数据
  39. *
  40. *@paramurlString
  41. *@return
  42. *@throwsIOException
  43. */
  44. public static StringgetRequestHttp(StringurlString) throws IOException{
  45. return getRequestHttp(urlString, "utf-8" );
  46. }
  47. /**
  48. *向指定url发送请求并获得响应数据
  49. *
  50. *@paramurlString
  51. *@paramencoding
  52. *@return
  53. *@throwsIOException
  54. */
  55. public static StringgetRequestHttp(StringurlString,Stringencoding)
  56. throws IOException{
  57. return getRequestHttp(urlString,encoding, null , 5000 );
  58. }
  59. /**
  60. *向指定url发送请求并获得响应数据
  61. *
  62. *@paramurlString
  63. *@paramencoding
  64. *@paramparameter
  65. *@return
  66. *@throwsIOException
  67. */
  68. public static StringgetRequestHttp( final StringurlString,
  69. final Stringencoding, final Mapparameter, final int timeout)
  70. throws IOException{
  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. boolean foundRedirect= false ;
  81. Mapheaders= new HashMap();
  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. } else if ( "pass" .equals(key)){
  91. password=value;
  92. } else if ( "method" .equals(key)){
  93. method=value;
  94. } else if ( "post" .equals(key)){
  95. post=value;
  96. } else {
  97. headers.put(key,value);
  98. }
  99. }
  100. }
  101. URLurl= new URL(nURL);
  102. if (user!= null &&password!= null ){
  103. BASE64Encoderbase64= new BASE64Encoder();
  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= new OutputStreamWriter(
  134. urlConnection.getOutputStream());
  135. outRemote.write(post);
  136. outRemote.flush();
  137. }
  138. //获得响应状态
  139. int responseCode=urlConnection.getResponseCode();
  140. //获得返回的数据长度
  141. int responseLength=urlConnection.getContentLength();
  142. if (responseCode== 302 ){
  143. //重定向
  144. Stringlocation=urlConnection.getHeaderField( "Location" );
  145. url= new URL(location);
  146. foundRedirect= true ;
  147. } else {
  148. BufferedInputStreamin;
  149. if (responseCode== 200 ||responseCode== 201 ){
  150. in= new BufferedInputStream(urlConnection.getInputStream());
  151. } else {
  152. in= new BufferedInputStream(urlConnection.getErrorStream());
  153. }
  154. int size=responseLength==- 1 ? 4096 :responseLength;
  155. if (encoding!= null ){
  156. responseContent=SimpleWebClient.read(in,size,encoding);
  157. } else {
  158. ByteArrayOutputStreamout= new ByteArrayOutputStream();
  159. byte []bytes= new byte [size];
  160. int read;
  161. while ((read=in.read(bytes))>= 0 ){
  162. out.write(bytes, 0 ,read);
  163. }
  164. responseContent= new String(out.toByteArray());
  165. in.close();
  166. out.close();
  167. }
  168. foundRedirect= false ;
  169. }
  170. //如果重定向则继续
  171. } while (foundRedirect);
  172. return responseContent;
  173. }
  174. /**
  175. *转化InputStream为String
  176. *
  177. * @param in
  178. * @param size
  179. * @return
  180. * @throws IOException
  181. */
  182. private static Stringread( final InputStreamin, final int size,
  183. final Stringencoding) throws IOException{
  184. StringBuildersbr= new StringBuilder();
  185. int nSize=size;
  186. if (nSize== 0 ){
  187. nSize= 1 ;
  188. }
  189. char []buffer= new char [nSize];
  190. int offset= 0 ;
  191. InputStreamReaderisr= new InputStreamReader(in,encoding);
  192. while ((offset=isr.read(buffer))!=- 1 ){
  193. sbr.append(buffer, 0 ,offset);
  194. }
  195. in.close();
  196. isr.close();
  197. return sbr.toString();
  198. }
  199. }

WebAppraise.java
  1. package org.loon.test;
  2. import java.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:ceponline@yahoo.com.cn
  21. *@version0.1
  22. */
  23. public class WebAppraise{
  24. private StringgoogleSum;
  25. private StringbaiduSum;
  26. private StringmsnSum;
  27. private StringaltaVistaSum;
  28. private StringallTheWebSum;
  29. private StringyahooSum;
  30. private StringtestURL;
  31. public WebAppraise( final Stringurl){
  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. throw new RuntimeException( "urlisNULL!" );
  42. }
  43. }
  44. /**
  45. *分析指定链接结果,并返回整型数值
  46. *
  47. *@paramsearchURL
  48. *@paramanchor
  49. *@paramtrail
  50. *@return
  51. */
  52. private static int getLinks( final StringsearchURL, final Stringanchor,
  53. final Stringtrail){
  54. int count= 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. int pos=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. return count;
  78. }
  79. public StringgetAllTheWebSite(){
  80. return getAllTheWebSite( false );
  81. }
  82. public StringgetAllTheWebSite( boolean isDomain){
  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. return allTheWebSum;
  99. }
  100. public StringgetAltaVistaSite(){
  101. return getAltaVistaSite( false );
  102. }
  103. public StringgetAltaVistaSite( boolean isDomain){
  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. return altaVistaSum;
  118. }
  119. public StringgetGooglePR(){
  120. return GooglePageRank.GooglePR( this .testURL);
  121. }
  122. public StringgetGoogleSite(){
  123. return getGoogleSite( false );
  124. }
  125. public StringgetGoogleSite( final boolean isDomian){
  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. return googleSum;
  141. }
  142. public StringgetBaiduSite(){
  143. return getBaiduSite( false );
  144. }
  145. public StringgetBaiduSite( final boolean isDomian){
  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. return baiduSum;
  166. }
  167. public StringgetYahooSite(){
  168. return getYahooSite( false );
  169. }
  170. public StringgetYahooSite( final boolean isDomian){
  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. return yahooSum;
  186. }
  187. public StringgetMsnSite(){
  188. return getMsnSite( false );
  189. }
  190. public StringgetMsnSite( boolean isDomain){
  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. return msnSum;
  205. }
  206. public StringgetTestURL(){
  207. return testURL;
  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:ceponline@yahoo.com.cn
  20. *@version0.1
  21. */
  22. public class Test{
  23. public static void main(String[]args){
  24. WebAppraiseappraise= new WebAppraise( "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

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


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论