Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I parse an HTML document with JSoup to get a list of links?
    text
    copied!<p>I am trying to parse <a href="http://www.craigslist.org/about/sites" rel="nofollow">http://www.craigslist.org/about/sites</a> to build a set of text/links to load a program dynamically with this information. So far I have done this:</p> <pre><code>Document doc = Jsoup.connect("http://www.craigslist.org/about/sites").get(); Elements elms = doc.select("div.colmask"); // gets 7 countries </code></pre> <p>Below this tag there are <code>doc.select("div.state_delimiter,ul")</code> tags I am trying to get. I setup my iterator and go into a while look and call <code>iterator.next().outerHtml();</code>. I see all the tags for each country.</p> <p>How can I step through each <code>div.state_delimiter</code>, pull that text then go down until there is a <code>&lt;/ul&gt;</code> which defines the end of the states individual counties/cities links/text?</p> <p>I was playing around with this and can do it by setting <code>outerHtml()</code> to a <code>String</code> and then parsing the string manually, but I am sure there is an easier way to do this. I have tried <code>text()</code> and also tried <code>attr("div.state_delimiter")</code>, but I think I am messing up the pattern/routine to do this properly. Was wondering if someone could help me out here and show me how to get the div.state_delimiter into a text field and then the <code>&lt;ul&gt;&lt;li&gt;&lt;/li&gt;&lt;/ul&gt;</code> I want all the <code>&lt;li&gt;&lt;/li&gt;</code> under the <code>&lt;ul&gt;&lt;/ul&gt;</code> for each state. Looking to grab the http:// &amp;&amp; html that goes along with it as easy as possible.</p>
 

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