String categ = "";
pos = details.indexOf("]");
if (pos >= 0) {
- categ = details.substring(1, pos + 1).trim();
+ categ = details.substring(1, pos).trim();
}
String author = "";
pos = details.indexOf(" Posted ");
if (pos >= 0) {
date = details.substring(pos + " Posted ".length()).trim();
- pos = details.indexOf(" by ");
+ pos = date.indexOf(" by ");
if (pos >= 0) {
- author = details.substring(0, pos).trim();
+ date = date.substring(0, pos).trim();
}
}
String details = "";
Elements detailsElements = article.getElementsByTag("div");
if (detailsElements.size() > 0) {
- details = detailsElements.get(0).text();
+ details = detailsElements.get(0).text().trim();
}
+ String author = "";
+ int pos = details.indexOf("by ");
+ if (pos >= 0) {
+ author = details.substring(pos + "by ".length()).trim();
+ pos = author.indexOf(" in ");
+ if (pos >= 0) {
+ author = author.substring(0, pos).trim();
+ }
+ }
+
+ String categ = "";
+ pos = details.indexOf(" in ");
+ if (pos >= 0) {
+ categ = details.substring(pos + " in ".length()).trim();
+ pos = categ.indexOf(" on ");
+ if (pos >= 0) {
+ categ = categ.substring(0, pos).trim();
+ }
+ }
+
+ String date = "";
+ Element dateElement = article.getElementsByTag("time").first();
+ if (dateElement != null) {
+ date = date(dateElement.attr("datetime"));
+ }
+
+ // We already have all the details (date, author, id, categ)
+ details = "";
+
String body = "";
for (Element elem : article.children()) {
String tag = elem.tag().toString();
}
}
- list.add(new Story(getType(), id, title.text(), "", "", "",
- details, intUrl, extUrl, body));
+ list.add(new Story(getType(), id, title.text(), author, date,
+ categ, details, intUrl, extUrl, body));
}
return list;
}
Elements links = title.getElementsByTag("a");
- String intUrl = null;
- String extUrl = null;
+ String intUrl = "";
+ String extUrl = "";
if (links.size() > 0) {
intUrl = links.get(0).absUrl("href");
}
Element dateElement = doc.getElementsByTag("time").first();
if (dateElement != null) {
date = StringUtils.unhtml(dateElement.text()).trim();
+ if (date.startsWith("on ")) {
+ date = date.substring("on ".length());
+ }
}
list.add(new Story(getType(), id, title.text(), author, date,
details += StringUtils.unhtml(detailsElement.text()).trim();
}
+ // We have some "details" but no content, so we switch them:
+ body = details;
+ details = "";
list.add(new Story(getType(), id, title, author, date, categ,
details, intUrl, extUrl, body));
}