本文整理匯總了Java中jodd.jerry.JerryFunction類的典型用法代碼示例。如果您正苦於以下問題:Java JerryFunction類的具體用法?Java JerryFunction怎麽用?Java JerryFunction使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
JerryFunction類屬於jodd.jerry包,在下文中一共展示了JerryFunction類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getPartnerNameFromTransparencyRegister
import jodd.jerry.JerryFunction; //導入依賴的package包/類
private String getPartnerNameFromTransparencyRegister(String string) {
try {
File file = new File(SystemUtil.tempDir(), "partner.html");
NetUtil.downloadFile(
"http://ec.europa.eu/transparencyregister/public/consultation/displaylobbyist.do?id=" + string,
file);
name = "";
// create Jerry, i.e. document context
Jerry doc = Jerry.jerry(FileUtil.readString(file));
// parse
doc.$("div.panel-body h4").each(new JerryFunction() {
public boolean onNode(Jerry $this, int index) {
name = $this.$("b").text();
return true;
}
});
} catch (IOException e) {
e.printStackTrace();
}
log.info(name);
return name;
}
示例2: parse
import jodd.jerry.JerryFunction; //導入依賴的package包/類
public static List<Book> parse(String page, final String username){
books.clear();
Jerry doc = Jerry.jerry(page);
// final List<Book> books = new ArrayList<Book>();
doc.$(CLASSNAME).each(new JerryFunction() {
Book book = new Book(username);
@Override
public boolean onNode(Jerry $this, int index) {
if (index % 8 == 0) {
book = new Book(username);
books.add(book);
}
BookInjection.init(book, index, $this.text());
return true;
}
});
return books;
}
示例3: parseCourses
import jodd.jerry.JerryFunction; //導入依賴的package包/類
/**
* Parses a given Jerry node and returns the courses
* @param page The Jerry node to be parsed
* @return A list of parsed courses
*/
private static List<Course> parseCourses(Jerry page) {
final List<Course> courses = new ArrayList<Course>();
Node node = page.$(Constants.COURSE_LIST).get(0);
if (node != null) {
page.$(Constants.COURSE).each(new JerryFunction() {
public boolean onNode(Jerry jerry, int i) {
String[] cName = jerry.text().split("\n");
String[] href = jerry.attr("href").split("/");
Course course = new Course(href[href.length - 1].trim(), cName[1].trim());
courses.add(course);
return true;
}
});
}
return courses;
}
示例4: parseAnnouncements
import jodd.jerry.JerryFunction; //導入依賴的package包/類
/**
* Parses the given Jerry object to a list of announcements
* @param page The Jerry object to be parsed
* @return A list of announcements
*/
private static List<Announcement> parseAnnouncements(Jerry page) {
final List<Announcement> announcements = new ArrayList<Announcement>();
page.$(Constants.ANNOUNCEMENT_LIST).each(new JerryFunction() {
public boolean onNode(Jerry jerry, int i) {
Announcement announcement = parseAnnouncement(jerry);
if(announcement != null) {
announcements.add(announcement);
}
return true;
}
});
return announcements;
}