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


Java TagNode.getElementsByName方法代码示例

本文整理汇总了Java中org.htmlcleaner.TagNode.getElementsByName方法的典型用法代码示例。如果您正苦于以下问题:Java TagNode.getElementsByName方法的具体用法?Java TagNode.getElementsByName怎么用?Java TagNode.getElementsByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.htmlcleaner.TagNode的用法示例。


在下文中一共展示了TagNode.getElementsByName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: login_2_2

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
public static String login_2_2(String redirectUri, String account,
                               String password) throws Exception {
    try {
        String result = Connector.getDataByGet(redirectUri, "big5");
        TagNode tagNode;
        tagNode = new HtmlCleaner().clean(result);
        TagNode[] nodes = tagNode.getElementsByName("input", true);
        String __VIEWSTATE = nodes[0].getAttributeByName("value");
        String __EVENTVALIDATION = nodes[1].getAttributeByName("value");

        HashMap<String, String> params = new HashMap<>();
        params.put("__VIEWSTATE", __VIEWSTATE);
        params.put("__EVENTVALIDATION",
                __EVENTVALIDATION);
        params.put("__EVENTTARGET", "");
        params.put("__EVENTARGUMENT", "");
        params.put("TxtBox_loginName", account);
        params.put("TxtBox_password", password);
        params.put("btnSubmit_AD", "登入");
        result = Connector.getDataByPost(redirectUri, params, "big5");
        return result;
    } catch (Exception e) {
        throw new Exception("Ntutcc登入時發生錯誤");
    }
}
 
开发者ID:kamisakihideyoshi,项目名称:TaipeiTechRefined,代码行数:26,代码来源:NtutccLoginConnector.java

示例2: getYearList

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
public static ArrayList<String> getYearList() throws Exception {
    try {
        ArrayList<String> year_list = new ArrayList<>();
        HashMap<String, String> params = new HashMap<>();
        params.put("format", "-1");
        String result = Connector
                .getDataByPost(getStandardUri(lang), params, "big5");
        TagNode tagNode;
        tagNode = new HtmlCleaner().clean(result);
        TagNode[] rows = tagNode.getElementsByName("a", true);
        for (TagNode row : rows) {
            String year = row.getText().toString();
            year_list.add(year);
        }
        return year_list;
    } catch (Exception e) {
        e.printStackTrace();
        throw new Exception("入學年度清單讀取時發生錯誤");
    }
}
 
开发者ID:kamisakihideyoshi,项目名称:TaipeiTechRefined,代码行数:21,代码来源:CreditConnector.java

示例3: getDivisionList

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
public static ArrayList<String> getDivisionList(String year)
        throws Exception {
    try {
        matrics.clear();
        ArrayList<String> division_list = new ArrayList<>();
        HashMap<String, String> params = new HashMap<>();
        params.put("format", "-2");
        params.put("year", year);
        String result = Connector
                .getDataByPost(getStandardUri(lang), params, "big5");
        TagNode tagNode;
        tagNode = new HtmlCleaner().clean(result);
        TagNode[] rows = tagNode.getElementsByName("a", true);
        for (TagNode row : rows) {
            String division = row.getText().toString();
            String[] temp = row.getAttributeByName("href").split("=");
            String matric = temp[temp.length - 1];
            matrics.add(matric);
            division_list.add(division);
        }
        return division_list;
    } catch (Exception e) {
        e.printStackTrace();
        throw new Exception("學制清單讀取時發生錯誤");
    }
}
 
开发者ID:kamisakihideyoshi,项目名称:TaipeiTechRefined,代码行数:27,代码来源:CreditConnector.java

示例4: JoinedBefore

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
public static boolean JoinedBefore(ChatPlayer mp, int year, int month, int day) throws Exception {
	URL url = new URL("https://www.reddit.com/u/" + mp.UserName());
	URLConnection con = url.openConnection();
	con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
	InputStream in = con.getInputStream();
	HtmlCleaner cleaner = new HtmlCleaner();
	TagNode node = cleaner.clean(in);

	node = node.getElementsByAttValue("class", "age", true, true)[0];
	node = node.getElementsByName("time", false)[0];
	String joindate = node.getAttributeByName("datetime");
	SimpleDateFormat parserSDF = new SimpleDateFormat("yyyy-MM-dd");
	joindate = joindate.split("T")[0];
	Date date = parserSDF.parse(joindate);
	return date.before(new Calendar.Builder().setTimeZone(TimeZone.getTimeZone("UTC")).setDate(year, month, day)
			.build().getTime());
}
 
开发者ID:TBMCPlugins,项目名称:ButtonChat,代码行数:18,代码来源:PluginMain.java

示例5: getCurrentCredit

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
private static StudentCredit getCurrentCredit(StudentCredit studentCredit) {
    try {
        String result = Connector.getDataByGet(CURRENT_URI, "big5");
        if (result.contains("查無本學期選課資料")) {
            return studentCredit;
        }
        TagNode tagNode;
        tagNode = new HtmlCleaner().clean(result);
        TagNode[] titles = tagNode.getElementsByName("H3", true);
        SemesterCredit semester = new SemesterCredit();
        String[] temp = titles[0].getText().toString().split("學年度 第 ");
        semester.setYear(temp[0]);
        semester.setSemester(temp[1].substring(0, 1));
        TagNode[] rows = tagNode.getElementsByName("tr", true);
        for (int i = 1; i < rows.length; i++) {
            TagNode[] cols = rows[i].getElementsByName("td", true);
            CreditInfo credit = new CreditInfo();
            credit.setCourseNo(cols[0].getText().toString());
            credit.setCourseName(cols[2].getText().toString());
            cols = rows[i].getElementsByName("th", true);
            credit.setCredit((int) Double.parseDouble(cols[0].getText()
                    .toString()));
            credit.setScore("XD");
            credit.setType(0);
            semester.addCreditInfo(credit);
        }
        studentCredit.addSemesterCredit(semester);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return studentCredit;
}
 
开发者ID:kamisakihideyoshi,项目名称:TaipeiTechRefined,代码行数:33,代码来源:CreditConnector.java

示例6: getCourseCount

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
private static int getCourseCount(String result) {
    TagNode tagNode;
    tagNode = new HtmlCleaner().clean(result);
    TagNode[] nodes = tagNode.getElementsByAttValue("border", "1", true,
            false);
    int count = 0;
    for (TagNode table : nodes) {
        TagNode[] rows = table.getElementsByName("tr", true);
        for (int i = 1; i < rows.length - 6; i++) {
            count++;
        }
    }
    return count;

}
 
开发者ID:kamisakihideyoshi,项目名称:TaipeiTechRefined,代码行数:16,代码来源:CreditConnector.java

示例7: login_2_1

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
public static String login_2_1(String uri, String account, String password)
        throws Exception {
    try {
        String result = Connector.getDataByGet(uri, "big5");
        TagNode tagNode;
        tagNode = new HtmlCleaner().clean(result);
        TagNode[] nodes = tagNode.getElementsByName("A", true);
        String redirectUri = nodes[0].getAttributeByName("HREF");
        redirectUri = redirectUri.replace("amp;", "");
        result = login_2_2(redirectUri, account, password);
        return result;
    } catch (Exception e) {
        throw new Exception("Ntutcc登入時發生錯誤");
    }
}
 
开发者ID:kamisakihideyoshi,项目名称:TaipeiTechRefined,代码行数:16,代码来源:NtutccLoginConnector.java

示例8: GetCourseDetail

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
public static ArrayList<String> GetCourseDetail(String courseNo)
        throws Exception {
    try {
        if (!isLogin) {
            loginCourse();
        }
        ArrayList<String> courseDetail = new ArrayList<>();
        HashMap<String, String> params = new HashMap<>();
        params.put("format", "-1");
        params.put("code", courseNo);
        String result = Connector.getDataByPost(getCourseUri("zh"), params, "big5");
        TagNode tagNode;
        tagNode = new HtmlCleaner().clean(result);
        TagNode[] tables = tagNode.getElementsByAttValue("border", "1",
                true, false);

        TagNode[] rows = tables[0].getElementsByName("tr", true);
        for (TagNode row : rows) {
            TagNode[] cols = row.getElementsByName("th", true);
            String d = cols[0].getText().toString();
            cols = row.getElementsByName("td", true);
            d = d + ":" + cols[0].getText().toString();
            d = d.replace(" ", " ");
            d = d.replace("\n", " ");
            courseDetail.add(d);
        }
        return courseDetail;
    } catch (Exception e) {
        isLogin = false;
        throw new Exception("課程資訊讀取時發生錯誤");
    }
}
 
开发者ID:kamisakihideyoshi,项目名称:TaipeiTechRefined,代码行数:33,代码来源:CourseConnector.java

示例9: getGeneralCredit

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
private static StudentCredit getGeneralCredit(StudentCredit studentCredit) {
    try {
        String result = Connector.getDataByGet(GENERAL_URI, "big5");
        TagNode tagNode;
        tagNode = new HtmlCleaner().clean(result);
        TagNode[] rows = tagNode.getElementsByName("tr", true);
        GeneralCredit general = null;
        for (int i = 2; i < rows.length; i++) {
            TagNode[] cols = rows[i].getElementsByName("td", true);
            if (cols.length == 10) {
                general = new GeneralCredit();
                general.setTypeName(cols[0].getText().toString());
                String mustCoreCredit = cols[1].getText().toString();
                mustCoreCredit = Utility.cleanString(mustCoreCredit);
                if (mustCoreCredit.length() > 0) {
                    general.setMustCoreCredit((int) Double
                            .parseDouble(mustCoreCredit));
                }
                studentCredit.addGeneralCredit(general);
            }
            String sem = cols[cols.length - 6].getText().toString();
            sem = Utility.cleanString(sem);
            if (sem.length() > 0) {
                GeneralCreditInfo course = new GeneralCreditInfo();
                course.setYear(sem.split("-")[0]);
                course.setSem(sem.split("-")[1]);
                if (cols[cols.length - 5].getText().toString()
                        .contains("*")) {
                    course.setCore(true);
                }
                course.setCourseName(cols[cols.length - 3].getText()
                        .toString());
                course.setCredit((int) Double
                        .parseDouble(cols[cols.length - 2].getText()
                                .toString()));
                general.addGeneral(course);
            }
        }
    } catch (Exception ex) {
        isHaveError = true;
        studentCredit.getGeneralCredits().clear();
    }
    return studentCredit;
}
 
开发者ID:kamisakihideyoshi,项目名称:TaipeiTechRefined,代码行数:45,代码来源:CreditConnector.java

示例10: select

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
@Override
    public String select(String text) {
        HtmlCleaner htmlCleaner = new HtmlCleaner();
        TagNode tagNode = htmlCleaner.clean(text);
        if (tagNode == null) {
            return null;
        }
        TagNode[] nodes = tagNode.getElementsByName("p", true);
        TagNode[] pres = tagNode.getElementsByName("pre", true);
        Map<TagNode, Double> pDensityCountMap = new HashMap<TagNode, Double>();
        countPdensity(nodes, pDensityCountMap);
        countPdensity(pres, pDensityCountMap);
        for (TagNode pre : pres) {
            addCounter(pre, pDensityCountMap, 2);
        }
        List<Map.Entry<TagNode, Double>> sortList = new ArrayList<Map.Entry<TagNode, Double>>();
        if (pDensityCountMap.size() == 0) {
            return null;
        }
        for (Map.Entry<TagNode, Double> entry : pDensityCountMap.entrySet()) {
//            if (logger.isDebugEnabled()) {
//                logger.debug("p\t" + entry.getKey().getName() + "#" + entry.getKey().getAttributeByName("id") +
//                        "@" + entry.getKey().getAttributeByName("class") + ":" + entry.getValue());
//            }
            sortList.add(entry);
        }

        Collections.sort(sortList, new Comparator<Map.Entry<TagNode, Double>>() {
            @Override
            public int compare(Map.Entry<TagNode, Double> o1, Map.Entry<TagNode, Double> o2) {
                Double d1 = o1.getValue();
                Double d2 = o2.getValue();
                return -d1.compareTo(d2);
            }
        });
        TagNode contentNode = sortList.get(0).getKey();
        if (logger.isDebugEnabled()) {
            logger.debug("p\t" + contentNode.getName() + "#" + contentNode.getAttributeByName("id") +
                    "@" + contentNode.getAttributeByName("class"));
        }
        return htmlCleaner.getInnerHtml(contentNode);
    }
 
开发者ID:yuany,项目名称:en-webmagic,代码行数:43,代码来源:SmartContentSelector.java


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