本文整理汇总了Java中org.jsoup.select.Elements.size方法的典型用法代码示例。如果您正苦于以下问题:Java Elements.size方法的具体用法?Java Elements.size怎么用?Java Elements.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jsoup.select.Elements
的用法示例。
在下文中一共展示了Elements.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDetailContent
import org.jsoup.select.Elements; //导入方法依赖的package包/类
@Override
public Map<DetailActivity.parameter, Object> getDetailContent(String baseUrl, String currentUrl, byte[] result, Map<DetailActivity.parameter, Object> resultMap) throws UnsupportedEncodingException {
List<PicInfo> urls = new ArrayList<>();
Document document = Jsoup.parse(new String(result, "utf-8"));
Elements elements = document.select("#big-pic img");
Elements title = document.select("#photos h1");
String sTitle = title.size() > 0 ? title.get(0).text() : "";
Elements tags = document.select(".fbl a");
List<String> tagList = new ArrayList<>();
if (tags.size() > 0) {
for (Element tag : tags)
tagList.add(tag.text());
}
for (Element element : elements) {
PicInfo picInfo = new PicInfo()
.setTags(tagList)
.setTitle(sTitle)
.setPicUrl(element.attr("src"));
urls.add(picInfo);
}
resultMap.put(DetailActivity.parameter.CURRENT_URL, currentUrl);
resultMap.put(DetailActivity.parameter.RESULT, urls);
return resultMap;
}
示例2: populatePointsGivenToK
import org.jsoup.select.Elements; //导入方法依赖的package包/类
public void populatePointsGivenToK(Team team) {
int rankCounter = 0;
Element kPointsAllowedTable = kPointsAllowedURL.select("table").get(1);
Elements kPointsAllowedRows = kPointsAllowedTable.select("tr");
for (int i = 2; i < kPointsAllowedRows.size(); i++) {
Element row = kPointsAllowedRows.get(i);
Elements cols = row.select("td");
rankCounter++;
if(cols.get(0).text().contains(team.getName())) {
if (cols.get(2).text().contains("*")) {
team.setFpToKRank(rankCounter);
team.setFpToKAvg(Double.parseDouble(cols.get(10).text()));
break;
} else {
team.setFpToKRank(rankCounter);
team.setFpToKAvg(Double.parseDouble(cols.get(11).text()));
break;
}
}
}
}
示例3: getDyttChosenList
import org.jsoup.select.Elements; //导入方法依赖的package包/类
/**
* 获取dytt中间的资源分布
*/
public List<MovieModel> getDyttChosenList() {
List<MovieModel> dyttChosenModels = new ArrayList<>();
MovieModel model;
Elements select = document.select("div.title_all:has(a)");
Elements itemSelect = document.select("table[cellpadding=0]");
int size = select.size();
for (int i = 0; i < size - 1; i++) {
model = new MovieModel();
model.type = 0;
model.itemType = i;
model.title = select.get(i).text().replace(CHOSEN_SUFFIX, "");
model.url = select.get(i).select("a").attr("abs:href");
dyttChosenModels.add(model);
getDyttChosenItemList(i, dyttChosenModels, itemSelect.get(i).select("a[href]"));
}
return dyttChosenModels;
}
示例4: populatePointsGivenToDef
import org.jsoup.select.Elements; //导入方法依赖的package包/类
public void populatePointsGivenToDef(Team team) {
int rankCounter = 0;
Element defPointsAllowedTable = defPointsAllowedURL.select("table").get(0);
Elements defPointsAllowedRows = defPointsAllowedTable.select("tr");
for (int i = 3; i < defPointsAllowedRows.size(); i++) {
Element row = defPointsAllowedRows.get(i);
Elements cols = row.select("td");
rankCounter++;
if(cols.get(0).text().contains(team.getName())) {
if (cols.get(2).text().contains("*")) {
team.setFpToDefRank(rankCounter);
team.setFpToDefAvg(Double.parseDouble(cols.get(18).text()));
break;
} else {
team.setFpToDefRank(rankCounter);
team.setFpToDefAvg(Double.parseDouble(cols.get(19).text()));
break;
}
}
}
}
示例5: getParsedData
import org.jsoup.select.Elements; //导入方法依赖的package包/类
private List<Map<String, String>> getParsedData(Content content){
List<Map<String,String >> testData = new ArrayList<>();
JSONObject jsonObject = new JSONObject(content.toString());
JSONObject body = (JSONObject) jsonObject.get("body");
JSONObject storage = (JSONObject) body.get("storage");
Document doc = Jsoup.parse(storage.get("value").toString());
Elements tRows = doc.select("tr");
LOG.info("Парсим данные страницы");
for (Element row : tRows){
HashMap<String,String> rowData = new HashMap<>();
Elements tds = row.select("td[colspan!="+countColumns+"]");
if (tds.size()!=0 && (!tds.get(0).text().equals(""))){
rowData.put("dKey",tds.get(0).text());
rowData.put("dValue",tds.get(1).text());
rowData.put("dComment",tds.get(2).text());
rowData.put("dHltValue",tds.get(3).text());
rowData.put("dDevValue",tds.get(4).text());
testData.add(rowData);
}
LOG.debug(row.text());
}
return testData;
}
示例6: parse
import org.jsoup.select.Elements; //导入方法依赖的package包/类
@Override
public List<Proxy> parse(String html) {
Document document = Jsoup.parse(html);
Elements elements = document.select("table[id=ip_list] tr[class]");
List<Proxy> proxyList = new ArrayList<>(elements.size());
for (Element element : elements){
String ip = element.select("td:eq(1)").first().text();
String port = element.select("td:eq(2)").first().text();
String isAnonymous = element.select("td:eq(4)").first().text();
String type = element.select("td:eq(5)").first().text();
log.debug("parse result = "+type+"://"+ip+":"+port+" "+isAnonymous);
if(!anonymousFlag || isAnonymous.contains("匿")){
proxyList.add(new Proxy(ip, Integer.valueOf(port), type, Constant.TIME_INTERVAL));
}
}
return proxyList;
}
示例7: getContentNext
import org.jsoup.select.Elements; //导入方法依赖的package包/类
@Override
public String getContentNext(String baseUrl, String currentUrl, byte[] result) throws UnsupportedEncodingException {
Document document = Jsoup.parse(new String(result, "utf-8"));
Elements elements = document.select(".cp-pagenavi a.previous-comment-page");
if (elements.size() > 0)
return elements.get(0).attr("href");
return "";
}
示例8: doAnalysis
import org.jsoup.select.Elements; //导入方法依赖的package包/类
@Override
public List doAnalysis(String html) {
List<TermTeacherCoursePageBo> list = new ArrayList<TermTeacherCoursePageBo>();
if(html!=null){
Document doc = Jsoup.parse(html);
Element table = HTMLUtil.getTableByTableHeadWords(doc, headwords);
//开始解析
Elements trs = table.select("tr:gt(0)");
TermTeacherCoursePageBo preCourse=null;
for(Element tr:trs){
Elements tds = tr.select("td");
if(tds.size()<10) continue;
String tempCourse= tds.get(1).text().trim();
String tempCredit = tds.get(2).text().trim();
String tempTeachingWay=tds.get(3).text().trim();
String tempCourseType=tds.get(4).text().trim();
String tempCourseClassNo= tds.get(5).text().trim();
String tempClassName = tds.get(6).text().trim();
String tempStudentNum= tds.get(7).text().trim();
String tempTime= tds.get(8).text().trim();
String tempClassroom= tds.get(9).text().trim();
if(tempCourse == null ||tempCourse.equals("")){
preCourse = list.get(list.size()-1);
tempCourse = preCourse.getCourse();
if(tempCredit == null ||tempCredit.equals("")){
tempCredit = preCourse.getCredit();
}
if(tempTeachingWay == null ||tempTeachingWay.equals("")){
tempTeachingWay = preCourse.getTeachingWay();
}
if(tempCourseClassNo == null ||tempCourseClassNo.equals("")){
tempCourseClassNo = preCourse.getCourseClassNo();
}
if(tempCourseType == null ||tempCourseType.equals("")){
tempCourseType = preCourse.getCourseType();
}
if(tempClassName == null ||tempClassName.equals("")){
tempClassName = preCourse.getClassName();
}
if(tempStudentNum == null ||tempStudentNum.equals("")){
tempStudentNum = preCourse.getStudentNum();
}
if(tempClassroom == null ||tempClassroom.equals("")){
tempClassroom = preCourse.getClassroom();
}
}
TermTeacherCoursePageBo termTeacherCoursePageBo= new TermTeacherCoursePageBo();
termTeacherCoursePageBo.setClassName(tempClassName);
termTeacherCoursePageBo.setClassroom(tempClassroom);
termTeacherCoursePageBo.setCourseType(tempCourseType);
termTeacherCoursePageBo.setCourseClassNo(tempCourseClassNo);
termTeacherCoursePageBo.setCourse(tempCourse);
termTeacherCoursePageBo.setTime(tempTime);
termTeacherCoursePageBo.setCredit(tempCredit);
termTeacherCoursePageBo.setTeachingWay(tempTeachingWay);
termTeacherCoursePageBo.setStudentNum(tempStudentNum);
termTeacherCoursePageBo.setTerm(getTerm());
termTeacherCoursePageBo.setTeacher(getTeacher());
list.add(termTeacherCoursePageBo);
}
}
return list;
}
示例9: readStepContent
import org.jsoup.select.Elements; //导入方法依赖的package包/类
private void readStepContent(Elements elements) {
Elements contentElements = elements.select(DESIGN_TAG_CONTENT);
if (!contentElements.isEmpty()) {
Element contentElement = contentElements.get(0);
Elements children = contentElement.children();
if (children.size() > 1) {
String msg = "Only one child allowed for tag <" + DESIGN_TAG_CONTENT + ">";
throw new IllegalArgumentException(msg);
}
Component component = designContext.readDesign(children.first());
setContent(component);
}
}
示例10: smallToFull
import org.jsoup.select.Elements; //导入方法依赖的package包/类
/**
* If largest resolution for image at 'thumb' is found, starts downloading
* and returns null.
* If it finds a larger resolution on another page, returns the image URL.
* @param thumb Thumbnail URL
* @param page Page the thumbnail is retrieved from
* @return Highest-resolution version of the image based on thumbnail URL and the page.
*/
private String smallToFull(String thumb, String page) {
try {
// Fetch the image page
Response resp = Http.url(page)
.referrer(this.url)
.cookies(cookies)
.response();
cookies.putAll(resp.cookies());
Document doc = resp.parse();
Elements els = doc.select("img.dev-content-full");
String fsimage = null;
// Get the largest resolution image on the page
if (els.size() > 0) {
// Large image
fsimage = els.get(0).attr("src");
logger.info("Found large-scale: " + fsimage);
if (fsimage.contains("//orig")) {
return fsimage;
}
}
// Try to find the download button
els = doc.select("a.dev-page-download");
if (els.size() > 0) {
// Full-size image
String downloadLink = els.get(0).attr("href");
logger.info("Found download button link: " + downloadLink);
HttpURLConnection con = (HttpURLConnection) new URL(downloadLink).openConnection();
con.setRequestProperty("Referer",this.url.toString());
String cookieString = "";
for (Map.Entry<String, String> entry : cookies.entrySet()) {
cookieString = cookieString + entry.getKey() + "=" + entry.getValue() + "; ";
}
cookieString = cookieString.substring(0,cookieString.length() - 1);
con.setRequestProperty("Cookie",cookieString);
con.setRequestProperty("User-Agent", USER_AGENT);
con.setInstanceFollowRedirects(true);
con.connect();
int code = con.getResponseCode();
String location = con.getURL().toString();
con.disconnect();
if (location.contains("//orig")) {
fsimage = location;
logger.info("Found image download: " + location);
}
}
if (fsimage != null) {
return fsimage;
}
throw new IOException("No download page found");
} catch (IOException ioe) {
try {
logger.info("Failed to get full size download image at " + page + " : '" + ioe.getMessage() + "'");
String lessThanFull = thumbToFull(thumb, false);
logger.info("Falling back to less-than-full-size image " + lessThanFull);
return lessThanFull;
} catch (Exception e) {
return null;
}
}
}
示例11: getInternalVideoUrl
import org.jsoup.select.Elements; //导入方法依赖的package包/类
private String getInternalVideoUrl(String url) {
WriteLog.appendLog("getInternalVideoUrl(" + url + ") called");
String lVideoUrl = "";
try {
Document docdata = Jsoup.connect(url).userAgent(getUserAgent())
.referrer(getServerUrl())
.timeout(Parser.getParseTimeOut()).get();
Elements scriptEles = docdata.select("script");
Element script = null;
String text = "";
if (scriptEles != null) {
for (int i = 0; i < scriptEles.size(); i++) {
script = scriptEles.get(i);
text = script.data();
if (!text.contains("var v_src"))
continue;
String[] scriptText = text.split("\r\n");
if (scriptText != null) {
for (int j = 0; j < scriptText.length; j++) {
if (scriptText[j].contains("file:")) {
lVideoUrl = scriptText[j].trim();
lVideoUrl = lVideoUrl.substring(lVideoUrl.indexOf("h"), lVideoUrl.lastIndexOf(",") - 1).replace(" ", "%20");
break;
}
}
}
if (!TextUtils.isEmpty(lVideoUrl))
break;
}
}
} catch (IOException e) {
WriteLog.appendLog(Log.getStackTraceString(e));
}
return lVideoUrl;
}
示例12: getContent
import org.jsoup.select.Elements; //导入方法依赖的package包/类
@Override
public Map<ContentsActivity.parameter, Object> getContent(String baseUrl, String currentUrl, byte[] result, Map<ContentsActivity.parameter, Object> resultMap) throws UnsupportedEncodingException {
List<AlbumInfo> urls = new ArrayList<>();
Document document = Jsoup.parse(new String(result, "gb2312"));
Elements elements = document.select(".piclist li");
for (Element element : elements) {
AlbumInfo temp = new AlbumInfo();
Elements title = element.select("a:has(img) span");
if (title.size() > 0)
temp.setTitle(title.get(0).text());
Elements time = element.select(".b1");
if (time.size() > 0)
temp.setTime(time.get(0).text());
Elements album = element.select("a:has(img)");
temp.setAlbumUrl(baseUrl + album.attr("href"));
Elements pic = album.select("img");
if (pic.size() > 0)
temp.setPicUrl(pic.get(0).attr("src"));
urls.add(temp);
}
resultMap.put(ContentsActivity.parameter.CURRENT_URL, currentUrl);
resultMap.put(ContentsActivity.parameter.RESULT, urls);
return resultMap;
}
示例13: parseAuthorizationForm
import org.jsoup.select.Elements; //导入方法依赖的package包/类
private void parseAuthorizationForm() {
Document doc = Jsoup.parse(form1);
Elements element = doc.select("input[name=acctId]");
if (element.size() == 0) {
isFake3DS = true;
form2 = form1;
return;
}
acctId = element.get(0).attr("value");
}
示例14: getContentNext
import org.jsoup.select.Elements; //导入方法依赖的package包/类
@Override
public String getContentNext(String baseUrl, String currentUrl, byte[] result) throws UnsupportedEncodingException {
Document document = Jsoup.parse(new String(result, "utf-8"));
Elements elements = document.select("div.pager a.next");
if (elements.size() > 0)
return elements.get(0).attr("href");
return "";
}
示例15: getContentNext
import org.jsoup.select.Elements; //导入方法依赖的package包/类
@Override
public String getContentNext(String baseUrl, String currentUrl, byte[] result) throws UnsupportedEncodingException {
Document document = Jsoup.parse(new String(result, "utf-8"));
Elements elements = document.select(".paginator span.next a");
if (elements.size() > 0)
return baseUrl + elements.get(0).attr("href");
return "";
}