Jsoupはホームページの内容を取ります。

1192 ワード

	public static void main(String [] args) throws Exception{
		//      
		 Document document=Jsoup.connect("http://www.biquge5200.com/14_14620/").userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0)").get();
		 //          
		 Elements chapters=document.getElementsByTag("dd").select("a");
		 //          
		 String bookname= document.getElementById("info").getElementsByTag("h1").text();
	     String cover= document.getElementById("fmimg").select("img").attr("abs:src");//      
		 List list=new ArrayList();
		 for (Element e:chapters) {
			 String second_url=e.attr("abs:href");//      
			 Document contentDocument=Jsoup.connect(second_url).userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0)").get();
			 //    
			 String content=contentDocument.getElementById("content").text();
			 String chaptername=e.text();//   
			 EbookChapter chapter=new EbookChapter();
			 chapter.setChapter(chaptername);
			 chapter.setContent(content);
			 chapter.setCopyurl(second_url);
			 list.add(chapter);
		 }
		
	}