자바 네트워크 파충류

1285 단어
가 져 오기 의존

      org.jsoup
      jsoup
      1.12.1

코드
package com.xsh.crawler;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;

public class Crawler {
    public void jsoupList(String url){
        try {
            Document document = Jsoup.connect(url).get();
            //    css           a   
            Elements elements = document.select("div#sy_load > ul > li > div.syl_pic > a > img");
            for (Element element:elements){
//                System.out.println(element);
                //        
                String d_url = element.attr("src");
                String title = element.attr("alt");
                System.out.println("  " + d_url + "       " + title);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        String url = "https://www.ivsky.com/";
        Crawler crawlerBase = new Crawler();
        crawlerBase.jsoupList(url);
    }
}

좋은 웹페이지 즐겨찾기