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


Java Elements.iterator方法代码示例

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


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

示例1: parseDateStatesMap

import org.jsoup.select.Elements; //导入方法依赖的package包/类
public static Map<Integer, String> parseDateStatesMap(String html) {
    int i = html.indexOf("<table id=\"calendar\"");
    if(i == -1)
        return null;
    int j = html.indexOf("</table>", i);
    Document document = JsoupDocumentUtils.parseUTF8HTMLDocument(html.substring(i, j + "</table>".length()));
    Element table = document.getElementById("calendar");
    Elements tds = table.getElementsByTag("td");
    Map<Integer, String> map = new HashMap<Integer, String>();
    int date = 1;
    for(Iterator<Element> iter = tds.iterator(); iter.hasNext(); ) {
        Element td = iter.next();
        Element child = td.children().first();
        if(child != null) {
            String className = child.className();
            if(!className.isEmpty()) {
                map.put(date++, className);
            }
        }
    }
    return map;
}
 
开发者ID:hulang1024,项目名称:PTEAssistant,代码行数:23,代码来源:AppointmentParser.java

示例2: parseSearchTestCenters

import org.jsoup.select.Elements; //导入方法依赖的package包/类
public static List<Map<String, Object>> parseSearchTestCenters(String html) {
    int i = html.indexOf("<table id=\"apptable\"");
    if(i == -1)
        return null;
    int j = html.indexOf("</table>", i);
    Document document = JsoupDocumentUtils.parseUTF8HTMLDocument(html.substring(i, j + "</table>".length()));
    Element table = document.getElementsByTag("tbody").get(0);
    Elements trs = table.getElementsByTag("tr");
    List<Map<String, Object>> testCenterList = new ArrayList<Map<String, Object>>();
    for(Iterator<Element> iter = trs.iterator(); iter.hasNext(); ) {
        Elements tds = iter.next().getElementsByTag("td");
        Map<String, Object> testCenter = new HashMap<String, Object>();
        testCenter.put("centerID", Long.valueOf(tds.get(0).attr("id").substring(1)));
        testCenter.put("name", tds.get(2).text());
        testCenter.put("distance", tds.get(4).html().replaceAll("&nbsp;", "").trim());
        testCenter.put("city", tds.get(5).text().trim());
        testCenter.put("state", tds.get(6).html().replaceAll("&nbsp;", "").trim());
        testCenter.put("country", tds.get(7).text().trim());
        testCenterList.add(testCenter);
    }
    return testCenterList;
}
 
开发者ID:hulang1024,项目名称:PTEAssistant,代码行数:23,代码来源:AppointmentParser.java

示例3: parseAppointmentTestCenters

import org.jsoup.select.Elements; //导入方法依赖的package包/类
public static List<Map<String, Object>> parseAppointmentTestCenters(String html) {
    int i = html.indexOf("<div id=\"choosecenter\"");
    if(i == -1)
        return null;
    int j = html.indexOf("</div>", i);
    Document document = JsoupDocumentUtils.parseUTF8HTMLDocument(html.substring(i, j + "</div>".length()));
    Element table = document.getElementsByTag("table").get(0);
    Elements trs = table.getElementsByTag("tr");
    List<Map<String, Object>> testCenterList = new ArrayList<Map<String, Object>>();
    for(Iterator<Element> iter = trs.iterator(); iter.hasNext(); ) {
        Elements tds = iter.next().getElementsByTag("td");
        Map<String, Object> testCenter = new HashMap<String, Object>();
        Matcher m = Pattern.compile("\"(\\d+)\"").matcher(tds.get(0).child(0).attr("onclick"));
        m.find();
        testCenter.put("centerID", Long.parseLong(m.group(1)));
        testCenter.put("info", tds.get(1).text());
        testCenterList.add(testCenter);
    }
    return testCenterList;
}
 
开发者ID:hulang1024,项目名称:PTEAssistant,代码行数:21,代码来源:AppointmentParser.java

示例4: parseExams

import org.jsoup.select.Elements; //导入方法依赖的package包/类
public static List<Map<String, Object>> parseExams(String html) {
    int i = html.indexOf("<table cellspacing=\"0\" id=\"apptable\">");
    if(i == -1)
        return null;
    int j = html.indexOf("</table>", i);
    Document document = JsoupDocumentUtils.parseUTF8HTMLDocument(html.substring(i, j + "</table>".length()));
    Element table = document.getElementsByTag("tbody").get(0);
    Elements trs = table.getElementsByTag("tr");
    List<Map<String, Object>> examList = new ArrayList<Map<String, Object>>();
    for(Iterator<Element> iter = trs.iterator(); iter.hasNext(); ) {
        Elements tds = iter.next().getElementsByTag("td");
        Map<String, Object> exam = new HashMap<String, Object>();
        Matcher m = Pattern.compile("'\\S+examSeriesID=(\\d+)';").matcher(tds.get(0).child(0).attr("onclick"));
        m.find();
        exam.put("examSeriesID", Long.valueOf(m.group(1)));
        exam.put("code", tds.get(1).text());
        exam.put("name", tds.get(3).text());
        examList.add(exam);
    }
    return examList;
}
 
开发者ID:hulang1024,项目名称:PTEAssistant,代码行数:22,代码来源:AppointmentParser.java

示例5: replace

import org.jsoup.select.Elements; //导入方法依赖的package包/类
private static void replace(Elements elements, String attrName) {
    String cdnDomain = Jboot.config(JbootRenderConfig.class).getCdn();
    Iterator<Element> iterator = elements.iterator();
    while (iterator.hasNext()) {

        Element element = iterator.next();

        if (element.hasAttr("cdn-exclude")) {
            continue;
        }

        String url = element.attr(attrName);
        if (StringUtils.isBlank(url) || !url.startsWith("/") || url.startsWith("//")) {
            continue;
        }

        url = cdnDomain + url;

        element.attr(attrName, url);
    }
}
 
开发者ID:yangfuhai,项目名称:jboot,代码行数:22,代码来源:RenderHelpler.java

示例6: getResults

import org.jsoup.select.Elements; //导入方法依赖的package包/类
private Map<Integer, List<TeamResult>> getResults(String leagueName) throws IOException{
    String url = GlobalConfiguration.baseURL + leagueName + GlobalConfiguration.calendarSuffix;
    Document doc = Jsoup.connect(url).get();
    Map<Integer, List<TeamResult>> results = new HashMap<>();
    Elements calendarDays = doc.select(".table");
    Iterator it = calendarDays.iterator();
    int day = 1;
    while (it.hasNext()) {
        Element calendarDay = (Element) it.next();
        if (calendarDay.children().is(".greyfoot")) {
            break;
        }
        List<TeamResult> teamResults = new ArrayList<>();
        for (Element match : calendarDay.select(".match")) {
            teamResults.add(new TeamResult(match.children().get(0).text(), Double.parseDouble(match.children().get(1).text().replace(",", "."))));
            teamResults.add(new TeamResult(match.children().get(3).text(), Double.parseDouble(match.children().get(2).text().replace(",", "."))));
        }
        results.put(day, teamResults);
        day++;
    }
    return results;
}
 
开发者ID:antpas14,项目名称:fantalegheEV,代码行数:23,代码来源:RemoteController.java

示例7: getBandTypes

import org.jsoup.select.Elements; //导入方法依赖的package包/类
public static Elements getBandTypes(Elements searchLinks, FilterType filterType)
{
	for(Iterator<Element> i = searchLinks.iterator(); i.hasNext();) {
		Element itemType = i.next().parent().select("div[class*=itemtype]").first();
		if(itemType.hasText() && StringUtils.isNotBlank(itemType.text().trim()) && !itemType.text().equalsIgnoreCase(filterType.toString()))
		{
			i.remove();
		}
	}
	return searchLinks;
}
 
开发者ID:scriptkittie,项目名称:bandcamp-api,代码行数:12,代码来源:JSONUtil.java

示例8: parseAvailableAppointmentTimes

import org.jsoup.select.Elements; //导入方法依赖的package包/类
public static List<Calendar> parseAvailableAppointmentTimes(String html) {
    int i = html.indexOf("<div id=\"divList\">");
    if(i == -1)
        return null;
    int j = html.indexOf("</div>", i);
    String divListHtml = html.substring(i, j + "</div>".length());
    List<Calendar> calendars = new ArrayList<Calendar>();
    Document doc = JsoupDocumentUtils.parseUTF8HTMLDocument(divListHtml);
    Elements as = doc.getElementsByTag("a");
    String[] monthSimpleNameArray = new String[]{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
    String[] weekSimpleNameArray = new String[]{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
    
    for(Iterator<Element> iter = as.iterator(); iter.hasNext(); ) {
        String timeStr = iter.next().text();
        if(timeStr.matches("\\w{3} \\d{1,2} \\w{3} at \\d{1,2}:\\d{1,2}.*")) {
            String[] parts = timeStr.split(" ");
            Calendar cal = Calendar.getInstance();
            cal.clear();
            int month = ArrayUtils.indexOf(monthSimpleNameArray, parts[2]);
            int dayOfWeek = ArrayUtils.indexOf(weekSimpleNameArray, parts[0]);
            if(month != -1 && dayOfWeek != -1) {
                cal.set(Calendar.MONTH, month);
                cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(parts[1]));
                cal.set(Calendar.DAY_OF_WEEK, dayOfWeek);
                if(parts.length > 5) {
                    switch(parts[5]){
                    case "AM": cal.set(Calendar.AM_PM, Calendar.AM);break;
                    case "PM": cal.set(Calendar.AM_PM, Calendar.PM); break;
                    }
                }
                String[] hms = parts[4].split(":");
                int hour = Integer.parseInt(hms[0]);
                cal.set(Calendar.HOUR, hour == 12 ? 0 : hour);//12小时制,值为0-11
                cal.set(Calendar.MINUTE, Integer.parseInt(hms[1]));
                calendars.add(cal);
            }
        }
    }
    return calendars;
}
 
开发者ID:hulang1024,项目名称:PTEAssistant,代码行数:41,代码来源:AppointmentParser.java


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