博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Java版PageRank及网站收录情况查询代码
阅读量:2200 次
发布时间:2019-05-03

本文共 16080 字,大约阅读时间需要 53 分钟。

                  
  在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.  * Copyright 2008
  8.  * 
  9.  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  10.  * use this file except in compliance with the License. You may obtain a copy of
  11.  * the License at
  12.  * 
  13.  * http://www.apache.org/licenses/LICENSE-2.0
  14.  * 
  15.  * Unless required by applicable law or agreed to in writing, software
  16.  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  17.  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  18.  * License for the specific language governing permissions and limitations under
  19.  * the License.
  20.  * 
  21.  * @project loonframework
  22.  * @author chenpeng
  23.  * @email:ceponline@yahoo.com.cn
  24.  * @version 0.1
  25.  */
  26. public class GooglePageRank {
  27.     // google pagerank服务器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(000);
  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.      * @param mix
  51.      */
  52.     private static void mix(final CHMix mix) {
  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 CHMix getInnerCHMix() {
  87.         return new GooglePageRank().new CHMix();
  88.     }
  89.     /**
  90.      * 通过url获得googlech(google数据库针对页面的全球唯一标识)
  91.      * 
  92.      * @param url
  93.      * @return
  94.      */
  95.     public static String GoogleCH(final String url) {
  96.         // 格式化为google要求的info:url模式
  97.         String nUrl = String.format("info:%s"new Object[] { url });
  98.         // 获得新url字符串格式
  99.         char[] urls = nUrl.toCharArray();
  100.         // 获得新url长度
  101.         int length = urls.length;
  102.         // 获得一个ch数值混合器
  103.         CHMix chMix = 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.         String tch = 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.      * @param value
  164.      * @return
  165.      */
  166.     private static String MatchRank(final String value) {
  167.         Pattern pattern = Pattern.compile("Rank_1:[0-9]:([0-9]+)");
  168.         Matcher matcher = pattern.matcher(value);
  169.         if (matcher.find()) {
  170.             return matcher.group(1);
  171.         }
  172.         return "0";
  173.     }
  174.     /**
  175.      * 获得指定页面的google pagerank值
  176.      * 
  177.      * @param url
  178.      * @return
  179.      */
  180.     public static String GooglePR(final String url) {
  181.         String rip = GoogleServiceIP[new Random()
  182.                 .nextInt(GoogleServiceIP.length)];
  183.         return GooglePR(url, rip);
  184.     }
  185.     /**
  186.      * 以指定的google服务器获得指定页面的google pagerank值
  187.      * 
  188.      * @param url
  189.      * @param ip
  190.      * @return
  191.      */
  192.     public static String GooglePR(final String url, final String ip) {
  193.         // 产生查询用唯一标识
  194.         String checksum = GoogleCH(url);
  195.         // 产生查询用url
  196.         String queryUrl = String
  197.                 .format(
  198.                         "http://%s/search?client=navclient-auto&ch=%s&features=Rank&q=info:%s",
  199.                         new Object[] { ip, checksum, url });
  200.         String response;
  201.         try {
  202.             response = SimpleWebClient.getRequestHttp(queryUrl);
  203.         } catch (IOException e) {
  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.  * Copyright 2008
  18.  * 
  19.  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  20.  * use this file except in compliance with the License. You may obtain a copy of
  21.  * the License at
  22.  * 
  23.  * http://www.apache.org/licenses/LICENSE-2.0
  24.  * 
  25.  * Unless required by applicable law or agreed to in writing, software
  26.  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  27.  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  28.  * License for the specific language governing permissions and limitations under
  29.  * the License.
  30.  * 
  31.  * @project loonframework
  32.  * @author chenpeng
  33.  * @email:ceponline@yahoo.com.cn
  34.  * @version 0.1
  35.  */
  36. public class SimpleWebClient {
  37.     /**
  38.      * 向指定url发送请求并获得响应数据
  39.      * 
  40.      * @param urlString
  41.      * @return
  42.      * @throws IOException
  43.      */
  44.     public static String getRequestHttp(String urlString) throws IOException {
  45.         return getRequestHttp(urlString, "utf-8");
  46.     }
  47.     /**
  48.      * 向指定url发送请求并获得响应数据
  49.      * 
  50.      * @param urlString
  51.      * @param encoding
  52.      * @return
  53.      * @throws IOException
  54.      */
  55.     public static String getRequestHttp(String urlString, String encoding)
  56.             throws IOException {
  57.         return getRequestHttp(urlString, encoding, null5000);
  58.     }
  59.     /**
  60.      * 向指定url发送请求并获得响应数据
  61.      * 
  62.      * @param urlString
  63.      * @param encoding
  64.      * @param parameter
  65.      * @return
  66.      * @throws IOException
  67.      */
  68.     public static String getRequestHttp(final String urlString,
  69.             final String encoding, final Map parameter, final int timeout)
  70.             throws IOException {
  71.         String nURL = (urlString.startsWith("http://") || urlString
  72.                 .startsWith("https://")) ? urlString : ("http:" + urlString)
  73.                 .intern();
  74.         String user = null;
  75.         String password = null;
  76.         String method = "GET";
  77.         String post = null;
  78.         String digest = null;
  79.         String responseContent = "ERROR";
  80.         boolean foundRedirect = false;
  81.         Map headers = new HashMap();
  82.         if (parameter != null) {
  83.             Set entrySet = parameter.entrySet();
  84.             for (Iterator it = entrySet.iterator(); it.hasNext();) {
  85.                 Entry header = (Entry) it.next();
  86.                 String key = (String) header.getKey();
  87.                 String value = (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.         URL url = new URL(nURL);
  102.         if (user != null && password != null) {
  103.             BASE64Encoder base64 = new BASE64Encoder();
  104.             digest = "Basic "
  105.                     + base64.encode((user + ":" + password).getBytes());
  106.         }
  107.         do {
  108.             HttpURLConnection urlConnection = (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; MSIE 7.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.             Set headersSet = headers.entrySet();
  127.             for (Iterator it = headersSet.iterator(); it.hasNext();) {
  128.                 Entry entry = (Entry) it.next();
  129.                 urlConnection.setRequestProperty((String) entry.getKey(),
  130.                         (String) entry.getValue());
  131.             }
  132.             if (post != null) {
  133.                 OutputStreamWriter outRemote = 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.                 String location = urlConnection.getHeaderField("Location");
  145.                 url = new URL(location);
  146.                 foundRedirect = true;
  147.             } else {
  148.                 BufferedInputStream in;
  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.                     ByteArrayOutputStream out = 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 String read(final InputStream in, final int size,
  183.             final String encoding) throws IOException {
  184.         StringBuilder sbr = 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.         InputStreamReader isr = 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.  * Copyright 2008
  5.  * 
  6.  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  7.  * use this file except in compliance with the License. You may obtain a copy of
  8.  * the License at
  9.  * 
  10.  * http://www.apache.org/licenses/LICENSE-2.0
  11.  * 
  12.  * Unless required by applicable law or agreed to in writing, software
  13.  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  14.  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  15.  * License for the specific language governing permissions and limitations under
  16.  * the License.
  17.  * 
  18.  * @project loonframework
  19.  * @author chenpeng
  20.  * @email:ceponline@yahoo.com.cn
  21.  * @version 0.1
  22.  */
  23. public class WebAppraise {
  24.     private String googleSum;
  25.     private String baiduSum;
  26.     private String msnSum;
  27.     private String altaVistaSum;
  28.     private String allTheWebSum;
  29.     private String yahooSum;
  30.     private String testURL;
  31.     public WebAppraise(final String url) {
  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("url is NULL!");
  42.         }
  43.     }
  44.     /**
  45.      * 分析指定链接结果,并返回整型数值
  46.      * 
  47.      * @param searchURL
  48.      * @param anchor
  49.      * @param trail
  50.      * @return
  51.      */
  52.     private static int getLinks(final String searchURL, final String anchor,
  53.             final String trail) {
  54.         int count = 0;
  55.         String serverResponse;
  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 (IOException e) {
  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.             String value = 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 String getAllTheWebSite() {
  80.         return getAllTheWebSite(false);
  81.     }
  82.     public String getAllTheWebSite(boolean isDomain) {
  83.         try {
  84.             String allTheWeb;
  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, "<span class=/"ofSoMany/">",
  94.                             "</span>");
  95.         } catch (Exception ex) {
  96.             allTheWebSum = ex.getMessage();
  97.         }
  98.         return allTheWebSum;
  99.     }
  100.     public String getAltaVistaSite() {
  101.         return getAltaVistaSite(false);
  102.     }
  103.     public String getAltaVistaSite(boolean isDomain) {
  104.         try {
  105.             String altaVista;
  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, "AltaVista found "" ");
  114.         } catch (Exception ex) {
  115.             altaVistaSum = ex.getMessage();
  116.         }
  117.         return altaVistaSum;
  118.     }
  119.     public String getGooglePR() {
  120.         return GooglePageRank.GooglePR(this.testURL);
  121.     }
  122.     public String getGoogleSite() {
  123.         return getGoogleSite(false);
  124.     }
  125.     public String getGoogleSite(final boolean isDomian) {
  126.         try {
  127.             String google;
  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 (Exception ex) {
  138.             googleSum = ex.getMessage();
  139.         }
  140.         return googleSum;
  141.     }
  142.     public String getBaiduSite() {
  143.         return getBaiduSite(false);
  144.     }
  145.     public String getBaiduSite(final boolean isDomian) {
  146.         try {
  147.             String baidu;
  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 (Exception ex) {
  156.             String baidu;
  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 String getYahooSite() {
  168.         return getYahooSite(false);
  169.     }
  170.     public String getYahooSite(final boolean isDomian) {
  171.         try {
  172.             String yahoo;
  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 (Exception ex) {
  183.             yahooSum = ex.getMessage();
  184.         }
  185.         return yahooSum;
  186.     }
  187.     public String getMsnSite() {
  188.         return getMsnSite(false);
  189.     }
  190.     public String getMsnSite(boolean isDomain) {
  191.         try {
  192.             String msn;
  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 (Exception ex) {
  202.             msnSum = ex.getMessage();
  203.         }
  204.         return msnSum;
  205.     }再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!

转载地址:http://teeub.baihongyu.com/

你可能感兴趣的文章
深入理解JVM虚拟机9:JVM监控工具与诊断实践
查看>>
深入理解JVM虚拟机10:JVM常用参数以及调优实践
查看>>
深入理解JVM虚拟机11:Java内存异常原理与实践
查看>>
深入理解JVM虚拟机12:JVM性能管理神器VisualVM介绍与实战
查看>>
深入理解JVM虚拟机13:再谈四种引用及GC实践
查看>>
Spring源码剖析1:Spring概述
查看>>
Spring源码剖析2:初探Spring IOC核心流程
查看>>
Spring源码剖析3:Spring IOC容器的加载过程
查看>>
Spring源码剖析4:懒加载的单例Bean获取过程分析
查看>>
Spring源码剖析5:JDK和cglib动态代理原理详解
查看>>
Spring源码剖析6:Spring AOP概述
查看>>
Spring源码剖析7:AOP实现原理详解
查看>>
Spring源码剖析8:Spring事务概述
查看>>
Spring源码剖析9:Spring事务源码剖析
查看>>
重新学习Mysql数据库1:无废话MySQL入门
查看>>
探索Redis设计与实现2:Redis内部数据结构详解——dict
查看>>
探索Redis设计与实现3:Redis内部数据结构详解——sds
查看>>
探索Redis设计与实现4:Redis内部数据结构详解——ziplist
查看>>
探索Redis设计与实现6:Redis内部数据结构详解——skiplist
查看>>
探索Redis设计与实现5:Redis内部数据结构详解——quicklist
查看>>