Created
October 4, 2011 14:22
-
-
Save shelling/1261756 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.jsoup.Jsoup; | |
| import org.jsoup.nodes.*; | |
| import org.jsoup.select.*; | |
| public class HelloParser { | |
| public static void main(String[] args) { | |
| try { | |
| Document doc = Jsoup.parse("<html><body><p class=content>內容</p></body></html>"); | |
| Element p = doc.select("p.content").first(); | |
| System.out.println(p.html()); | |
| } catch (Exception e) { | |
| e.printStackTrace(); | |
| } | |
| try { | |
| Document doc = Jsoup.connect("https://market.android.com/search?q=twitter").get(); | |
| Elements apps = doc.select("a.title"); | |
| for (Element app : apps) { | |
| System.out.println(app.attr("title")); | |
| } | |
| } catch (Exception e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment