当前位置: 首页>>代码示例>>Java>>正文


Java HtmlDocument类代码示例

本文整理汇总了Java中com.gistlabs.mechanize.document.html.HtmlDocument的典型用法代码示例。如果您正苦于以下问题:Java HtmlDocument类的具体用法?Java HtmlDocument怎么用?Java HtmlDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HtmlDocument类属于com.gistlabs.mechanize.document.html包,在下文中一共展示了HtmlDocument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: selectSchool

import com.gistlabs.mechanize.document.html.HtmlDocument; //导入依赖的package包/类
private HtmlDocument selectSchool(String siteURL, String schoolId) throws SchoolNotFoundException {
    MechanizeAgent agent = new MechanizeAgent();
    HtmlDocument page = agent.get(siteURL);
    Form schoolSelectionForm = page.forms().get(0);
    Select schoolDropdown = (Select) schoolSelectionForm.get("PsiId");
    List<Select.Option> schools = schoolDropdown.getOptions();
    Select.Option schoolOption = null;
    for(Select.Option school : schools) {
        if (school.getValue().equals(schoolId)) {
            schoolOption = school;
        }
    }
    if (schoolOption != null) {
        schoolOption.setSelected(true);
    }
    else {
        throw new SchoolNotFoundException();
    }
    return schoolSelectionForm.submit();
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:21,代码来源:UPassLoader.java

示例2: login

import com.gistlabs.mechanize.document.html.HtmlDocument; //导入依赖的package包/类
/**
 * Obtains the raw html of the data.
 * 
 * @return Evalos
 */
public Evalos login() {
    try {
        final MechanizeAgent agent = new MechanizeAgent();
        final Document page = agent.get(WEB_APP_BASE_URL);

        Form form = page.form("form1");
        form.get("username").set(username);
        form.get("password").set(password);

        HtmlDocument document = form.submit();

        parseRawHtmlResponse(document);

    } catch (Exception e) {
        connectionProblem = true;
    }

    return this;
}
 
开发者ID:robertboloc,项目名称:ho.la.urv,代码行数:25,代码来源:Evalos.java

示例3: login

import com.gistlabs.mechanize.document.html.HtmlDocument; //导入依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
    Form authForm = authPage.form("aspnetForm");

    Text usernameField = (Text) authForm.get("ctl00$ContentPlaceHolder1$UsernameTextBox");
    Password passwordField = (Password) authForm.get("ctl00$ContentPlaceHolder1$PasswordTextBox");

    usernameField.setValue(username);
    passwordField.setValue(password);
    HtmlDocument nvitRedirect = authForm.submit();

    HtmlDocument submittedPage;
    try {
        HtmlDocument translinkRedirect = nvitRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
        submittedPage = translinkRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());

    }
    catch (Exception e) {
        throw new SchoolAuthenticationFailedException(e);
    }

    if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
        return submittedPage;
    } else {
        throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:30,代码来源:NVIT.java

示例4: login

import com.gistlabs.mechanize.document.html.HtmlDocument; //导入依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
    Form authForm = authPage.forms().get(0);    // form has no id or name

    Text usernameField = (Text) authForm.get("username");
    Password passwordField = (Password) authForm.get("password");

    usernameField.setValue(username);
    passwordField.setValue(password);
    HtmlDocument kuRedirect = authForm.submit();

    HtmlDocument submittedPage;
    try {
        HtmlDocument translinkRedirect = kuRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
        submittedPage = translinkRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());

    }
    catch (Exception e) {
        throw new SchoolAuthenticationFailedException(e);
    }

    if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
        return submittedPage;
    } else {
        throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:30,代码来源:KwantlenUniversity.java

示例5: login

import com.gistlabs.mechanize.document.html.HtmlDocument; //导入依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
    Form authForm = authPage.form("login");

    Text usernameField = (Text) authForm.get("username");
    Password passwordField = (Password) authForm.get("password");

    usernameField.setValue(username);
    passwordField.setValue(password);
    HtmlDocument bcitRedirect = authForm.submit();

    HtmlDocument submittedPage;
    try {
        HtmlDocument translinkRedirect = bcitRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
        submittedPage = translinkRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());

    }
    catch (Exception e) {
        throw new SchoolAuthenticationFailedException(e);
    }

    if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
        return submittedPage;
    } else {
        throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:30,代码来源:BCIT.java

示例6: login

import com.gistlabs.mechanize.document.html.HtmlDocument; //导入依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
    Form authForm = authPage.form("aspnetForm");

    Text usernameField = (Text) authForm.get("ctl00_ContentPlaceHolder1_UsernameTextBox");
    Password passwordField = (Password) authForm.get("ctl00_ContentPlaceHolder1_PasswordTextBox");

    usernameField.setValue(username);
    passwordField.setValue(password);
    HtmlDocument cuRedirect = authForm.submit();

    HtmlDocument submittedPage;
    try {
        HtmlDocument translinkRedirect = cuRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
        submittedPage = translinkRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());
    }
    catch (Exception e) {
        throw new SchoolAuthenticationFailedException(e);
    }

    if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
        return submittedPage;
    } else {
        throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:29,代码来源:CapilanoUniversity.java

示例7: login

import com.gistlabs.mechanize.document.html.HtmlDocument; //导入依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
    Form authForm = authPage.form("fm1");

    Text usernameField = (Text) authForm.get("username");
    Password passwordField = (Password) authForm.get("password");

    usernameField.setValue(username);
    passwordField.setValue(password);
    HtmlDocument ecuRedirect = authForm.submit();

    HtmlDocument submittedPage;
    try {
        HtmlDocument translinkRedirect = ecuRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
        submittedPage = translinkRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());

    }
    catch (Exception e) {
        throw new SchoolAuthenticationFailedException(e);
    }

    if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
        return submittedPage;
    } else {
        throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:30,代码来源:EmilyCarrUniversity.java

示例8: login

import com.gistlabs.mechanize.document.html.HtmlDocument; //导入依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
    Form authForm = authPage.form("aspnetForm");

    Text usernameField = (Text) authForm.get("ctl00$ContentPlaceHolder1$UsernameTextBox");
    Password passwordField = (Password) authForm.get("ctl00$ContentPlaceHolder1$PasswordTextBox");

    usernameField.setValue(username);
    passwordField.setValue(password);
    HtmlDocument dcRedirect = authForm.submit();

    HtmlDocument submittedPage;
    try {
        HtmlDocument translinkRedirect = dcRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
        submittedPage = translinkRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());

    }
    catch (Exception e) {
        throw new SchoolAuthenticationFailedException(e);
    }

    if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
        return submittedPage;
    } else {
        throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:30,代码来源:DouglasCollege.java

示例9: login

import com.gistlabs.mechanize.document.html.HtmlDocument; //导入依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
    Form authForm = authPage.form("aspnetForm");

    Text usernameField = (Text) authForm.get("ctl00$ContentPlaceHolder1$UsernameTextBox");
    Password passwordField = (Password) authForm.get("ctl00$ContentPlaceHolder1$PasswordTextBox");

    usernameField.setValue(username);
    passwordField.setValue(password);
    HtmlDocument vccRedirect = authForm.submit();

    HtmlDocument submittedPage;
    try {
        HtmlDocument translinkRedirect = vccRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
        submittedPage = translinkRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());

    }
    catch (Exception e) {
        throw new SchoolAuthenticationFailedException(e);
    }

    if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
        return submittedPage;
    } else {
        throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:30,代码来源:VancouverCommunityCollege.java

示例10: login

import com.gistlabs.mechanize.document.html.HtmlDocument; //导入依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
    Form authForm = authPage.form("loginForm");

    Text usernameField = (Text) authForm.get("userNameInput");
    Password passwordField = (Password) authForm.get("passwordInput");

    usernameField.setValue(username);
    passwordField.setValue(password);
    HtmlDocument lcRedirect = authForm.submit();

    HtmlDocument submittedPage;
    try {
        HtmlDocument translinkRedirect = lcRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
        submittedPage = translinkRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());
    }
    catch (Exception e) {
        throw new SchoolAuthenticationFailedException(e);
    }

    if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
        return submittedPage;
    } else {
        throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:29,代码来源:LangaraCollege.java

示例11: login

import com.gistlabs.mechanize.document.html.HtmlDocument; //导入依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
    Form authForm = authPage.form("loginForm");

    Text usernameField = (Text) authForm.get("j_username");
    Password passwordField = (Password) authForm.get("password");

    usernameField.setValue(username);
    passwordField.setValue(password);
    HtmlDocument ubcRedirect = authForm.submit();

    HtmlDocument submittedPage;
    try {
        HtmlDocument translinkRedirect = ubcRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
        submittedPage = translinkRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());
    }
    catch (Exception e) {
        throw new SchoolAuthenticationFailedException(e);
    }

    if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
        return submittedPage;
    } else {
        throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:29,代码来源:UniversityOfBritishColumbia.java

示例12: login

import com.gistlabs.mechanize.document.html.HtmlDocument; //导入依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
    Form authForm = authPage.form("fm1");

    Text usernameField = (Text) authForm.get("username");
    Password passwordField = (Password) authForm.get("password");

    usernameField.setValue(username);
    passwordField.setValue(password);
    HtmlDocument sfuRedirect = authForm.submit();

    HtmlDocument submittedPage;
    try {
        HtmlDocument translinkRedirect = sfuRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
        submittedPage = translinkRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());
    }
    catch (Exception e) {
        throw new SchoolAuthenticationFailedException(e);
    }

    if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
        return submittedPage;
    } else {
        throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:29,代码来源:SimonFraserUniversity.java

示例13: checkUpass

import com.gistlabs.mechanize.document.html.HtmlDocument; //导入依赖的package包/类
private boolean checkUpass(HtmlDocument upassPage) throws NothingToRenewException {
    Form requestForm = upassPage.form("form-request");
    Checkbox requestCheckbox = null;
    for (Object element : requestForm) {
        if (element instanceof Checkbox) {
            requestCheckbox = (Checkbox) element;
        }
    }
    if (requestCheckbox != null) {
        return true;
    }
    else {
        throw new NothingToRenewException();
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:16,代码来源:UPassLoader.java

示例14: requestUpass

import com.gistlabs.mechanize.document.html.HtmlDocument; //导入依赖的package包/类
private boolean requestUpass(HtmlDocument upassPage) {
    List prevRequestedUpasses = upassPage.findAll(".status");

    Form requestForm = upassPage.form("form-request");
    Checkbox requestCheckbox = requestForm.findCheckbox("input");
    requestCheckbox.check();
    String boxName = requestCheckbox.getName();
    Iterator elementIter = requestForm.iterator();
    while (elementIter.hasNext()) {
        Object element = elementIter.next();
        if (element instanceof Hidden) {
            Hidden hiddenElement = (Hidden) element;
            if (boxName.equals(hiddenElement.getName())) {
                elementIter.remove();
            }
        }
    }
    SubmitButton requestButton = requestForm.findSubmitButton("input");
    HtmlDocument resultPage = requestButton.submit();

    List requestedUpasses = resultPage.findAll(".status");
    if (requestedUpasses.size() > prevRequestedUpasses.size()) {
        return true;
    }
    else {
        return false;
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:29,代码来源:UPassLoader.java

示例15: safeGet

import com.gistlabs.mechanize.document.html.HtmlDocument; //导入依赖的package包/类
private HtmlDocument safeGet(MechanizeAgent agent, String url) {
    try {
        return agent.get(OMAMATKAKORTTI_URL_BASE + url);
    } catch (ClassCastException cce) {
        // MechanizeAgent throws this if not text/html
        throw new MatkakorttiException("Page " + url + " not HTML", cce, true);
    }
}
 
开发者ID:dezgeg,项目名称:matkakortti-widget,代码行数:9,代码来源:MatkakorttiApi.java


注:本文中的com.gistlabs.mechanize.document.html.HtmlDocument类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。