本文整理汇总了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;
}