About the font adjustments in the Eclipse Editor Rollup console:
1. Download the Jsoup jar package: Http://jsoup.org/download
2, Jsoup Development Handbook for English: http://jsoup.org/cookbook/
3,jsoup Jsoup Cookbook Chinese version: http://www.open-open.com/jsoup/
- - - - - &N Bsp - - - - and nbsp - - &N Bsp - - - & nbsp  - 
- - - - - - - - - - - - - - -
Small instance:
1 Packagecn.cast.test;2 3 4 5 ImportOrg.jsoup.Jsoup;6 Importorg.jsoup.nodes.Document;7 Importorg.jsoup.nodes.Element;8 Importorg.jsoup.select.Elements;9 Ten One Importjava.io.IOException; A - ImportOrg.jsoup.Jsoup; - ImportOrg.jsoup.Jsoup; the Importorg.jsoup.nodes.Document; - Importorg.jsoup.nodes.Element; - Importorg.jsoup.select.Elements; - + - Public classtest_1 { + A Public Static voidMain (string[] args) { at //TODO auto-generated Method Stub - geturlandtitle (); - gettextmes (); - } - - Public Static voidGeturlandtitle () in { -String url= "http://finance.sina.com.cn/"; to Try { +Document doc=jsoup.connect (URL). Timeout (10000). get ();//get all infomation from URL website - //System.out.println (DOC); theElements Listdiv = Doc.getelementsbyattributevalue ("Class", "fin_tabs0_c0"); * //System.out.println (listdiv); $ for(Element div:listdiv) {Panax NotoginsengElements links = Div.getelementsbytag ("a"); - //System.out.println (links); the for(Element link:links) { +String linkhref = link.attr ("href"). Trim (); AString LinkText =link.text (). Trim (); theSystem.out.println (linkhref+ "\ T" +linkText); + } - } $}Catch(IOException e) { $ //TODO auto-generated Catch block - e.printstacktrace (); - } the } - Wuyi Public Static voidgettextmes () the { -String url= "http://finance.sina.com.cn/hy/20140823/100220099682.shtml"; WuString textmes= ""; - Try { AboutDocument doc=jsoup.connect (URL). Timeout (10000). get (); $Elements Listdiv = Doc.getelementsbyattributevalue ("Class", "Blkcontainersblkcon Bshare_pop"); - //System.out.println (listdiv); - for(Element div:listdiv) - { AElements Textinfos=div.getelementsbytag ("P"); + //System.out.println (Textinfos); the for(Element Textinfo:textinfos) - { $String text=textinfo.text (). Trim (); theTextmes=textmes+text+ "\ n"; the } the } the System.out.println (textmes); -}Catch(IOException e) { in //TODO auto-generated Catch block the e.printstacktrace (); the } About } the}test_1
Jsoup parsing and traversing an HTML document (ii)