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

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

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

網(wǎng)頁爬蟲:其實(shí)就是一個(gè)程序用于在互聯(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; 
  } 
} 

總結(jié)

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

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

相關(guān)文章

最新評(píng)論