亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Java 從互聯(lián)網(wǎng)上爬郵箱代碼示例

 更新時間:2017年10月10日 08:42:39   作者:luoxn28  
這篇文章介紹了Java 從互聯(lián)網(wǎng)上爬郵箱的有關內(nèi)容,主要是一個代碼示例,小編覺得挺不錯的,這里給大家分享下,需要的朋友可以了解。

網(wǎng)頁爬蟲:其實就是一個程序用于在互聯(lián)網(wǎng)中獲取符合指定規(guī)則的數(shù)據(jù)。

package day05; 
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.net.URL; 
import java.util.ArrayList; 
import java.util.List; 
import java.util.regex.Matcher; 
import java.util.regex.Pattern; 
public class SpiderDemo { 
  public static void main(String[] args) throws IOException { 
    List<String> list = getMailByWeb(); 
    for (String mail : list) { 
      System.out.println(mail); 
    } 
  } 
  public static List<String> getMailByWeb() throws IOException { 
    URL url = new URL("http://www.itheima.com/aboutt/1376.html"); 
    BufferedReader input = new BufferedReader(new InputStreamReader(url.openStream())); 
    String regex = "\\w+@\\w+(\\.\\w+)+"; 
    Pattern p = Pattern.compile(regex); 
    List<String> list = new ArrayList<String>(); 
    String line = null; 
    while ((line = input.readLine()) != null) { 
      Matcher m = p.matcher(line); 
      while (m.find()) { 
        list.add(m.group()); 
      } 
    } 
    return list; 
  } 
} 

總結

 Jsoup解析html方法,通常被人稱之為爬蟲技術。(個人認為可能是返回的數(shù)據(jù),只有一小部分是我們需要的,造成了數(shù)據(jù)的冗余,和網(wǎng)絡延遲)。

以上就是本文關于Java 從互聯(lián)網(wǎng)上爬郵箱代碼示例的全部內(nèi)容,希望對大家有所幫助。感興趣的朋友可以參閱:Java多線程ForkJoinPool實例詳解、Java中map遍歷方式的選擇問題詳解、關于Java企業(yè)級項目開發(fā)思想等,有什么問題可以隨時留言,小編會及時回復大家。

相關文章

最新評論