use of org.jsoup.nodes.Element in project useful-java-links by Vedenin.
the class GithubDownLoadTests method printElements.
private static void printElements(Elements children) {
for (Element child : children) {
if (!child.text().isEmpty()) {
System.out.print(child.tag().getName() + " : ");
System.out.println(child.text());
}
printElements(child.children());
}
}
use of org.jsoup.nodes.Element in project useful-java-links by Vedenin.
the class URLDownloadTests method printElements.
private static void printElements(Elements children) {
for (Element child : children) {
if (!child.text().isEmpty()) {
System.out.print(child.tag().getName() + " : ");
System.out.println(child.text());
}
printElements(child.children());
}
}
use of org.jsoup.nodes.Element in project ZhihuDailyPurify by izzyleung.
the class NewsListFromZhihuObservable method getQuestions.
private static List<Question> getQuestions(Document document, String dailyTitle) {
List<Question> result = new ArrayList<>();
Elements questionElements = getQuestionElements(document);
for (Element questionElement : questionElements) {
Question question = new Question();
String questionTitle = getQuestionTitleFromQuestionElement(questionElement);
String questionUrl = getQuestionUrlFromQuestionElement(questionElement);
// Make sure that the question's title is not empty.
questionTitle = TextUtils.isEmpty(questionTitle) ? dailyTitle : questionTitle;
question.setTitle(questionTitle);
question.setUrl(questionUrl);
result.add(question);
}
return result;
}
use of org.jsoup.nodes.Element in project jsoup by jhy.
the class W3CDomTest method handlesInvalidAttributeNames.
@Test
public void handlesInvalidAttributeNames() {
String html = "<html><head></head><body style=\"color: red\" \" name\"></body></html>";
org.jsoup.nodes.Document jsoupDoc;
jsoupDoc = Jsoup.parse(html);
Element body = jsoupDoc.select("body").first();
// actually an attribute with key '"'. Correct per HTML5 spec, but w3c xml dom doesn't dig it
assertTrue(body.hasAttr("\""));
assertTrue(body.hasAttr("name\""));
Document w3Doc = new W3CDom().fromJsoup(jsoupDoc);
}
use of org.jsoup.nodes.Element in project jsoup by jhy.
the class ParseTest method testYahooJp.
@Test
public void testYahooJp() throws IOException {
File in = getFile("/htmltests/yahoo-jp.html");
// http charset is utf-8.
Document doc = Jsoup.parse(in, "UTF-8", "http://www.yahoo.co.jp/index.html");
assertEquals("Yahoo! JAPAN", doc.title());
Element a = doc.select("a[href=t/2322m2]").first();
assertEquals("http://www.yahoo.co.jp/_ylh=X3oDMTB0NWxnaGxsBF9TAzIwNzcyOTYyNjUEdGlkAzEyBHRtcGwDZ2Ex/t/2322m2", // session put into <base>
a.attr("abs:href"));
assertEquals("全国、人気の駅ランキング", a.text());
}
Aggregations