Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use JSoup parse .</p> <p>Here you go <a href="http://jsoup.org/cookbook/">http://jsoup.org/cookbook/</a></p> <p>JSoup is amazing and very effective you will find good example in above link.</p> <p><strong>First, You have to connect to the webpage you want to parse using:</strong></p> <pre><code>Document doc = Jsoup.connect("http://example.com/").get(); </code></pre> <p><strong>Make sure you execute above code in non-ui thread using Asynctask or handlers.</strong></p> <p>Then, you can select page elements using the <a href="http://jsoup.org/cookbook/extracting-data/selector-syntax">JSoup selector syntax</a>.</p> <p>For instance, say you want to select all the content of the <code>div</code> tags with the <code>id</code> attribute set to <code>test</code>, you just have to use:</p> <p><code>Elements divs = doc.select("div#test");</code></p> <p>to retrieve the divs, then you can iterate on them using:</p> <pre><code>for (Element div : divs) System.out.println(div.text()); } </code></pre> <p><strong>Below is Example Snippet.</strong></p> <pre><code>package org.jsoup.examples; import org.jsoup.Jsoup; import org.jsoup.helper.Validate; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; import java.io.IOException; /** * Example program to list links from a URL. */ public class ListLinks { public static void main(String[] args) throws IOException { Validate.isTrue(args.length == 1, "usage: supply url to fetch"); String url = args[0]; print("Fetching %s...", url); Document doc = Jsoup.connect(url).get(); Elements links = doc.select("a[href]"); Elements media = doc.select("[src]"); Elements imports = doc.select("link[href]"); print("\nMedia: (%d)", media.size()); for (Element src : media) { if (src.tagName().equals("img")) print(" * %s: &lt;%s&gt; %sx%s (%s)", src.tagName(), src.attr("abs:src"), src.attr("width"), src.attr("height"), trim(src.attr("alt"), 20)); else print(" * %s: &lt;%s&gt;", src.tagName(), src.attr("abs:src")); } print("\nImports: (%d)", imports.size()); for (Element link : imports) { print(" * %s &lt;%s&gt; (%s)", link.tagName(),link.attr("abs:href"), link.attr("rel")); } print("\nLinks: (%d)", links.size()); for (Element link : links) { print(" * a: &lt;%s&gt; (%s)", link.attr("abs:href"), trim(link.text(), 35)); } } private static void print(String msg, Object... args) { System.out.println(String.format(msg, args)); } private static String trim(String s, int width) { if (s.length() &gt; width) return s.substring(0, width-1) + "."; else return s; } } </code></pre> <p>Last but not list.</p> <blockquote> <p>If you ever do Asynchronous operation then perform it in Non-UI Thread.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload