本文整理汇总了Java中jodd.jerry.Jerry类的典型用法代码示例。如果您正苦于以下问题:Java Jerry类的具体用法?Java Jerry怎么用?Java Jerry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Jerry类属于jodd.jerry包,在下文中一共展示了Jerry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: completeLogin
import jodd.jerry.Jerry; //导入依赖的package包/类
/**
* Attempt to complete the login process
*/
private void completeLogin() {
Log.d(TAG, "completing login...");
mRequestFactory.get(mAuthUrl, true, new RequestListener() {
@Override
public void onSucceeded(URL url, String data) {
mListener.authProgress(80);
if (url.getPath().equals("/account/prompt")) {
Jerry doc = jerry(data);
mSessionId = doc.$("input[name=session]").attr("value");
mSessionFkey = doc.$("input[name=fkey]").attr("value");
if (mSessionId == null || mSessionId.isEmpty() ||
mSessionFkey == null || mSessionId.isEmpty()) {
mListener.authFailed(mContext.getResources().getText(R.string.se_auth_unable_to_read_session).toString());
} else {
confirmOpenId();
}
} else if (url.getPath().equals("/")) {
mListener.authSucceeded(mRequestFactory.cookies());
}
}
});
}
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:26,代码来源:StackExchangeAuth.java
示例2: getPartnerNameFromTransparencyRegister
import jodd.jerry.Jerry; //导入依赖的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;
}
开发者ID:TransparencyInternationalEU,项目名称:lobbycal,代码行数:27,代码来源:MeetingService.java
示例3: webFullName
import jodd.jerry.Jerry; //导入依赖的package包/类
public static String webFullName(final String firstName, final String href) {
String _xblockexpression = null;
{
Jerry _parts = TungParser.parts(href, ".listbox1 .listbox1_text");
String _text = _parts.text();
String[] _split = _text.split(firstName);
final Function1<String, Boolean> _function = (String it) -> {
boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(it);
return Boolean.valueOf((!_isNullOrEmpty));
};
Iterable<String> _filter = IterableExtensions.<String>filter(((Iterable<String>)Conversions.doWrapArray(_split)), _function);
final List<String> lastNames = IterableExtensions.<String>toList(_filter);
double _random = Math.random();
int _size = lastNames.size();
double _multiply = (_random * _size);
final int lastNameIndex = ((int) _multiply);
final String lastName = lastNames.get(lastNameIndex);
_xblockexpression = (firstName + lastName);
}
return _xblockexpression;
}
开发者ID:East196,项目名称:maker,代码行数:22,代码来源:Names.java
示例4: createTest
import jodd.jerry.Jerry; //导入依赖的package包/类
/**
* 创建测试邮件
* @param books
*/
public static String createTest(Map<String,String> books){
try {
Jerry doc = jerry(FileUtil.readString(Thread.currentThread().getContextClassLoader().getResource("/templateTest").getFile()));
for(Map.Entry<String,String> book:books.entrySet()){
doc.$("#booksContent").append(createNode(book));
}
return doc.htmlAll(true);
} catch (IOException e) {
e.printStackTrace();
System.out.println("未找到文件");
}
return null;
}
开发者ID:1994,项目名称:cdulibrary,代码行数:22,代码来源:TemplateFactory.java
示例5: parse
import jodd.jerry.Jerry; //导入依赖的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;
}
开发者ID:1994,项目名称:cdulibrary,代码行数:23,代码来源:Analysis.java
示例6: parseDocuments
import jodd.jerry.Jerry; //导入依赖的package包/类
/**
* Parses a Jerry node and returns the documents found within
* @param page A Jerry node containing documents
* @return A list of documents
*/
private static List<Document> parseDocuments(Jerry page) {
List<Document> documents = new ArrayList<Document>();
String head = page.$("head").first().html();
if(head != null){
Matcher m = DOCUMENT_REGEX.matcher(head);
if(m.find()){
String json = m.group(2).trim().substring(0, m.group(2).trim().length() - 1).trim();
JSONDocument jsonDocument = new Gson().fromJson(json, JSONDocument.class);
if(jsonDocument!= null && jsonDocument.getType().equals(Constants.TYPE_ROOT)){
if(jsonDocument.getItems() != null) {
documents.addAll(parseDirectory(jsonDocument.getItems()));
}
}
}
}
return documents;
}
开发者ID:pielambr,项目名称:Minerva4J,代码行数:23,代码来源:DocumentParser.java
示例7: parseCourses
import jodd.jerry.Jerry; //导入依赖的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;
}
开发者ID:pielambr,项目名称:Minerva4J,代码行数:22,代码来源:CourseParser.java
示例8: extract
import jodd.jerry.Jerry; //导入依赖的package包/类
@Override
public String extract(String data) {
Jerry doc = jerry(data);
String result = "";
switch (outType) {
case TYPE_TEXT:
result = parse(doc.$(query).first().text());
break;
case TYPE_HTML:
result = parse(doc.$(query).first().html());
break;
default:
result = parse(doc.$(query).first().attr(outType));
break;
}
return result;
}
开发者ID:fivesmallq,项目名称:web-data-extractor,代码行数:18,代码来源:JerryExtractor.java
示例9: extractList
import jodd.jerry.Jerry; //导入依赖的package包/类
@Override
public List<String> extractList(String data) {
List<String> strings = new LinkedList<>();
Jerry doc = jerry(data);
Node[] nodes = doc.$(query).get();
for (Node node : nodes) {
switch (outType) {
case TYPE_TEXT:
strings.add(parse(node.getTextContent()));
break;
case TYPE_HTML:
strings.add(parse(node.getHtml()));
break;
default:
strings.add(parse(node.getAttribute(outType)));
break;
}
}
return strings;
}
开发者ID:fivesmallq,项目名称:web-data-extractor,代码行数:21,代码来源:JerryExtractor.java
示例10: parse
import jodd.jerry.Jerry; //导入依赖的package包/类
private Page parse(String data)
{
// Begin by parsing the page
Jerry doc = jerry(data);
// Extract the room name and icon
String name = doc.$("#roomname").text();
String icon = doc.$("link[rel=shortcut icon]").attr("href");
// TODO: Extract a suitable color for the page
int color = 1;
return new Page(name, icon, color);
}
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:16,代码来源:PageRetriever.java
示例11: getTitle
import jodd.jerry.Jerry; //导入依赖的package包/类
/**
* getTitle receives a url parameter and return a Response object that hoold the page title
* @param url The HTML page url
* @return Response
*/
static Response getTitle(String url) {
HttpBrowser browser = new HttpBrowser();
HttpRequest request = HttpRequest.get(url);
browser.sendRequest(request);
String page = browser.getPage();
Jerry doc = Jerry.jerry(page);
return new Response(doc.$("title").text());
}
开发者ID:dimiro1,项目名称:gettitle,代码行数:16,代码来源:GetTitleService.java
示例12: verifyLogin
import jodd.jerry.Jerry; //导入依赖的package包/类
/**
* Verifies login for the user after calling connect
* @return Returns true if the login was correct
* @throws LoginFailedException Is thrown if the login was incorrect
*/
public boolean verifyLogin() throws LoginFailedException, IOException {
// Check index page
String response = _browser.get(Constants.INDEX_URL);
// Check to see if we find a course list
if (response != null) {
Jerry i = Jerry.jerry(response);
Node node = i.$(Constants.COURSE_LIST).get(0);
if (node != null) {
return true;
}
}
throw new LoginFailedException();
}
开发者ID:pielambr,项目名称:Minerva4J,代码行数:19,代码来源:MinervaClient.java
示例13: getDocuments
import jodd.jerry.Jerry; //导入依赖的package包/类
/**
* Returns a list of documents for the given course
* @param client An instance of the MinervaClient client
* @param course The course of which the documents need to be retrieved
* @return A list of documents
*/
public static List<Document> getDocuments(MinervaClient client, Course course) throws IOException {
String response = client.getClient().get(Constants.COURSE_URL + course.getCode() + Constants.DOCUMENT);
Jerry page;
try {
page = Jerry.jerry(new String(response.getBytes(), "UTF8"));
} catch (UnsupportedEncodingException ex){
page = Jerry.jerry(response);
}
client.checkLogin(client);
return parseDocuments(page);
}
开发者ID:pielambr,项目名称:Minerva4J,代码行数:18,代码来源:DocumentParser.java
示例14: getAnnouncements
import jodd.jerry.Jerry; //导入依赖的package包/类
/**
* Parses the course page for the given course and returns the announcements
* @param course The course for which the announcements need to be retrieved
* @param client The MinervaClient instance
* @return Returns a list of announcements for this course
*/
public static List<Announcement> getAnnouncements(MinervaClient client, Course course) throws IOException {
String response = client.getClient().get(Constants.COURSE_URL + course.getCode() + Constants.ANNOUNCEMENT);
Jerry coursePage;
try {
coursePage = Jerry.jerry(new String(response.getBytes(), "UTF-8"));
} catch (UnsupportedEncodingException e) {
coursePage = Jerry.jerry(response);
}
client.checkLogin(client);
return parseAnnouncements(coursePage);
}
开发者ID:pielambr,项目名称:Minerva4J,代码行数:18,代码来源:AnnouncementParser.java
示例15: parseAnnouncements
import jodd.jerry.Jerry; //导入依赖的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;
}
开发者ID:pielambr,项目名称:Minerva4J,代码行数:19,代码来源:AnnouncementParser.java
示例16: parseAnnouncement
import jodd.jerry.Jerry; //导入依赖的package包/类
/**
* Parses the Jerry object to an announcement object
* @param announcement the Jerry object to be converted
* @return An announcement object with a title, date and some content
*/
private static Announcement parseAnnouncement(Jerry announcement) {
String dateString = announcement.$(Constants.ANNOUNCEMENT_DATE).text();
Date date = parseDate(dateString);
String title = announcement.$(Constants.ANNOUNCEMENT_TITLE).text();
String content = announcement.$(Constants.ANNOUNCEMENT_BODY).html();
return new Announcement(content, title, date);
}
开发者ID:pielambr,项目名称:Minerva4J,代码行数:13,代码来源:AnnouncementParser.java
示例17: requiredAttributesAreParsedCorrectly
import jodd.jerry.Jerry; //导入依赖的package包/类
@Test
public void requiredAttributesAreParsedCorrectly() {
String generatedHtml = generateHtml("json_schema_required_properties.raml");
Jerry doc = jerry(generatedHtml);
String topLevelRequiredText = doc.$("div[data-property=\"toplevel\"]").$(".property-required .required-text").text();
assertThat(topLevelRequiredText).isEqualTo("required");
String draft3RequiredText = doc.$("div[data-property=\"draft3-required\"]").$(".property-required .required-text").text();
assertThat(draft3RequiredText).isEqualTo("required");
}
开发者ID:adrobisch,项目名称:raml-converter,代码行数:12,代码来源:Raml2HtmlConverterTest.java
示例18: configProxoolAlias
import jodd.jerry.Jerry; //导入依赖的package包/类
public static void configProxoolAlias(String jdbcUsername, String jdbcPassword, String jdbcUrl,
String jdbcDriverClassname, int fixedConnectioinSize) {
try {
StringBuffer htmlText = new StringBuffer();
if (ProxoolConfigTemplate != null && !ProxoolConfigTemplate.isEmpty()) {
htmlText.append(ProxoolConfigTemplate);
} else {
try (InputStream resource = ClassLoader.getSystemResourceAsStream(ProxoolFilename)) {
byte[] resourceConfigDatas = StreamUtil.readBytes(resource);
htmlText.append(new String(resourceConfigDatas, java.nio.charset.StandardCharsets.UTF_8));
}
}
Jerry doc = Jerry.jerry(htmlText.toString());
for (Jerry node : doc.$("proxool")) {
if (node.$("alias").text().equals(ProxoolAliasname)) {
node.$("driver-url").text(jdbcUrl);
node.$("driver-class").text(jdbcDriverClassname);
Jerry driverProperties = node.$("driver-properties property");
for (Jerry prop : driverProperties) {
if (prop.attr("name").equals("user"))
prop.attr("value", jdbcUsername);
else if (prop.attr("name").equals("password"))
prop.attr("value", jdbcPassword);
}
if (fixedConnectioinSize != 0) {
node.$("maximum-connection-count").text(String.valueOf(fixedConnectioinSize));
node.$("minimum-connection-count").text(String.valueOf(fixedConnectioinSize));
}
break;
}
}
String configXml = doc.html();
configXml = Toolset.deleteCRLFOnce(configXml);
Toolset.prettyOutput(log,
"ProxoolHelper Config {nl}{}",
configXml);
try (StringReader stringReader = new StringReader(configXml)) {
JAXPConfigurator.configure(stringReader, false);
}
} catch (Throwable e) {
log.info("[ProxoolHelper] initialize proxoool exceptioin !!!.", e);
}
}
开发者ID:316181444,项目名称:GameServerFramework,代码行数:53,代码来源:ProxoolHelper.java
示例19: parts
import jodd.jerry.Jerry; //导入依赖的package包/类
public static Jerry parts(final String url, final String expression) {
String _html = TungParser.html(url);
Jerry _jerry = Jerry.jerry(_html);
return _jerry.$(expression);
}
开发者ID:East196,项目名称:maker,代码行数:6,代码来源:TungParser.java
示例20: part
import jodd.jerry.Jerry; //导入依赖的package包/类
public static String part(final String html, final String expression) {
Jerry _jerry = Jerry.jerry(html);
Jerry _$ = _jerry.$(expression);
return _$.html();
}
开发者ID:East196,项目名称:maker,代码行数:6,代码来源:TungParser.java
注:本文中的jodd.jerry.Jerry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论