android - Jsoup parsing html not returning anything -
android - Jsoup parsing html not returning anything -
im trying headline content based on website: h t tp://w w w.a b c.net.au/news/2014-10-19/battle-for-kobane-intensifies/5825324
which entitled: battle kobane intensifies islamic state uses auto bombs, syrian fighters execute captives h1 tag , parent div tag. markup follows:
<div class="article section"> <h1>battle kobane intensifies islamic state uses auto bombs, syrian fighters execute captives</h1> <p class="published"> updated <span class="timestamp"> oct 20, 2014 01:05:03 </span> </p> </div>
my code:
document document = jsoup.connect(url).get(); elements headline = document.select("div[class=article section]").select("h1"); string desc = headline.text();
it not display anything. when seek extract article section div tag, not display also. there wrong code? or websites security?
i'm not sure description
variable responsible for, not appear in code @ beginning. anyway, have little fixes in code, here illustration of working headline scraping:
import org.jsoup.jsoup; import org.jsoup.nodes.document; import org.jsoup.nodes.element; import java.io.ioexception; public class abcnewsexample { public static void main(string[] args) throws ioexception { string url = "[put url here, blocks abc.net domain]"; document document = jsoup.connect(url).get(); element headline = document.select("div.page div.article > h1").first(); string title = headline.text(); // here check if title right assert "battle kobane intensifies islamic state uses auto bombs, syrian fighters execute captives".equals(title); } }
android html html5 jsoup
Comments
Post a Comment