本文整理汇总了Java中org.jsoup.select.Elements.get方法的典型用法代码示例。如果您正苦于以下问题:Java Elements.get方法的具体用法?Java Elements.get怎么用?Java Elements.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jsoup.select.Elements
的用法示例。
在下文中一共展示了Elements.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populatePointsGivenToQB
import org.jsoup.select.Elements; //导入方法依赖的package包/类
public void populatePointsGivenToQB(Team team) {
int rankCounter = 0;
Element qbPointsAllowedTable = qbPointsAllowedURL.select("table").get(1);
Elements qbPointsAllowedRows = qbPointsAllowedTable.select("tr");
for (int i = 2; i < qbPointsAllowedRows.size(); i++) {
Element row = qbPointsAllowedRows.get(i);
Elements cols = row.select("td");
rankCounter++;
if(cols.get(0).text().contains(team.getName())) {
if (cols.get(2).text().contains("*")) {
team.setFpToQBRank(rankCounter);
team.setFpToQBAvg(Double.parseDouble(cols.get(18).text()));
break;
} else {
team.setFpToQBRank(rankCounter);
team.setFpToQBAvg(Double.parseDouble(cols.get(19).text()));
break;
}
}
}
}
示例2: parseCollectionsRepositoryData
import org.jsoup.select.Elements; //导入方法依赖的package包/类
private Repository parseCollectionsRepositoryData(Element element) throws Exception{
String fullName = element.select("div > div > a").attr("href");
String owner = fullName.substring(1, fullName.lastIndexOf("/"));
String repoName = fullName.substring(fullName.lastIndexOf("/") + 1);
String ownerAvatar = element.select("div > div > a > img").attr("src");
Elements articleElements = element.getElementsByTag("div");
Element descElement = articleElements.get(articleElements.size() - 2);
StringBuilder desc = new StringBuilder("");
for(TextNode textNode : descElement.textNodes()){
desc.append(textNode.getWholeText());
}
Element numElement = articleElements.last();
String starNumStr = numElement.select("a").get(0).textNodes().get(1).toString();
String forkNumStr = numElement.select("a").get(1).textNodes().get(1).toString();
String language = "";
Elements languageElements = numElement.select("span > span");
if(languageElements.size() > 0){
language = numElement.select("span > span").get(1).textNodes().get(0).toString();
}
Repository repo = new Repository();
repo.setFullName(fullName);
repo.setName(repoName);
User user = new User();
user.setLogin(owner);
user.setAvatarUrl(ownerAvatar);
repo.setOwner(user);
repo.setDescription(desc.toString());
repo.setStargazersCount(Integer.parseInt(starNumStr.replaceAll(" ", "")));
repo.setForksCount(Integer.parseInt(forkNumStr.replaceAll(" ", "")));
repo.setLanguage(language);
return repo;
}
示例3: 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("div[class=videocontent]").select("video").select("source");
Element script = null;
String text = "";
if (scriptEles != null) {
for (int i = 0; i < scriptEles.size(); i++) {
script = scriptEles.get(i);
if (script != null && script.hasAttr("src"))
lVideoUrl = script.attr("src");
}
}
} catch (IOException e) {
WriteLog.appendLog(Log.getStackTraceString(e));
}
return lVideoUrl;
}
示例4: rip
import org.jsoup.select.Elements; //导入方法依赖的package包/类
@Override
public void rip() throws IOException {
logger.info(" Retrieving " + this.url);
Document doc = Http.url(this.url).get();
Elements embeds = doc.select("embed");
if (embeds.size() == 0) {
throw new IOException("Could not find Embed code at " + url);
}
Element embed = embeds.get(0);
String vars = embed.attr("flashvars");
for (String var : vars.split("&")) {
if (var.startsWith("flv_url=")) {
String vidUrl = var.substring("flv_url=".length());
vidUrl = URLDecoder.decode(vidUrl, "UTF-8");
addURLToDownload(new URL(vidUrl), HOST + "_" + getGID(this.url));
}
}
waitForThreads();
}
示例5: populatePointsGivenToTE
import org.jsoup.select.Elements; //导入方法依赖的package包/类
public void populatePointsGivenToTE(Team team) {
int rankCounter = 0;
Element tePointsAllowedTable = tePointsAllowedURL.select("table").get(1);
Elements tePointsAllowedRows = tePointsAllowedTable.select("tr");
for (int i = 2; i < tePointsAllowedRows.size(); i++) {
Element row = tePointsAllowedRows.get(i);
Elements cols = row.select("td");
rankCounter++;
if(cols.get(0).text().contains(team.getName())) {
if (cols.get(2).text().contains("*")) {
team.setFpToTERank(rankCounter);
team.setFpToTEAvg(Double.parseDouble(cols.get(18).text()));
break;
} else {
team.setFpToTERank(rankCounter);
team.setFpToTEAvg(Double.parseDouble(cols.get(19).text()));
break;
}
}
}
}
示例6: doAnalysis
import org.jsoup.select.Elements; //导入方法依赖的package包/类
public CourseListPage doAnalysis(String html){
if (html == null)
return null;
CourseListPage courseListPage = new CourseListPage();
Document doc = null;
doc = Jsoup.parse(html);
Elements tables = doc.select("table");
if (tables.size() < 2)
return null;
Element table = tables.get(1);
table.select("script").remove();
courseListPage.setMajorNo(getMajorNo());
table.select("input[type=checkbox]").removeAttr("disabled")
.removeAttr("checked");
table.select("input[type=text]").attr("value", "");
courseListPage.setPageContent(table.children().html()
.replaceAll("查看", "选择"));
return courseListPage;
}
示例7: getElIndexInSameTags
import org.jsoup.select.Elements; //导入方法依赖的package包/类
/**
* 获取同名元素在同胞中的index
* @param e
* @return
*/
public static int getElIndexInSameTags(Element e){
Elements chs = e.parent().children();
int index = 1;
for(int i=0;i<chs.size();i++){
Element cur = chs.get(i);
if (e.tagName().equals(cur.tagName())){
if (e.equals(cur)){
break;
}else {
index+=1;
}
}
}
return index;
}
示例8: populatePointsGivenToWR
import org.jsoup.select.Elements; //导入方法依赖的package包/类
public void populatePointsGivenToWR(Team team) {
int rankCounter = 0;
Element wrPointsAllowedTable = wrPointsAllowedURL.select("table").get(1);
Elements wrPointsAllowedRows = wrPointsAllowedTable.select("tr");
for (int i = 2; i < wrPointsAllowedRows.size(); i++) {
Element row = wrPointsAllowedRows.get(i);
Elements cols = row.select("td");
rankCounter++;
if(cols.get(0).text().contains(team.getName())) {
if (cols.get(2).text().contains("*")) {
team.setFpToWRRank(rankCounter);
team.setFpToWRAvg(Double.parseDouble(cols.get(18).text()));
break;
} else {
team.setFpToWRRank(rankCounter);
team.setFpToWRAvg(Double.parseDouble(cols.get(19).text()));
break;
}
}
}
}
示例9: getStringResNameAndValueMap
import org.jsoup.select.Elements; //导入方法依赖的package包/类
/**
* 获取strings.xml 资源名-值 映射表
*
* @return
*/
protected Map<String, String> getStringResNameAndValueMap() {
Map<String, String> map = new HashMap<>();
Document document = getValuesXmlDocument();
Elements strings = document.getElementsByTag("string");
for (int i = 0; i < strings.size(); i++) {
Element element = strings.get(i);
String name = element.attr("name");
if (element.childNodeSize() > 0 && element.childNode(0) instanceof TextNode) {
String text = ((TextNode) element.childNode(0)).text();
map.put(name, text);
}
}
return map;
}
示例10: readStepButtons
import org.jsoup.select.Elements; //导入方法依赖的package包/类
private void readStepButtons(Elements elements) {
Elements buttonsElements = elements.select(DESIGN_TAG_BUTTONS);
if (!buttonsElements.isEmpty()) {
Element buttonsElement = buttonsElements.get(0);
Elements children = buttonsElement.children();
if (children.size() > 4) {
String msg = "A maximum of 4 children allowed for tag <" + DESIGN_TAG_BUTTONS + ">";
throw new IllegalArgumentException(msg);
}
List<StepAction> stepActions = new ArrayList<>();
for (Element buttonElement : children) {
StepAction stepAction = readStepButton(buttonElement);
if (stepActions.contains(stepAction)) {
throw new IllegalArgumentException("Duplicate step action found: " + stepAction);
}
stepActions.add(stepAction);
}
}
}
示例11: GetDocContent
import org.jsoup.select.Elements; //导入方法依赖的package包/类
private static String GetDocContent(Document doc) {
Elements divs = doc.body().getElementsByTag("div");
int max = -1;
String content = null;
for (int i = 0; i < divs.size(); i++) {
Element div = (Element) divs.get(i);
String divContent = GetDivContent(div);
if (divContent.length() > max) {
max = divContent.length();
content = divContent;
}
}
return content;
}
示例12: rip
import org.jsoup.select.Elements; //导入方法依赖的package包/类
@Override
public void rip() throws IOException {
logger.info(" Retrieving " + this.url);
Document doc = Http.url(this.url).get();
Elements videos = doc.select("video");
if (videos.size() == 0) {
throw new IOException("Could not find Embed code at " + url);
}
Element video = videos.get(0);
String vidUrl = video.attr("src");
addURLToDownload(new URL(vidUrl), HOST + "_" + getGID(this.url));
waitForThreads();
}
示例13: element
import org.jsoup.select.Elements; //导入方法依赖的package包/类
public Element element(String cssSelector) {
Elements els = getDoc().select(cssSelector);
if (els == null || els.size() == 0) {
log.warn("所选元素不存在" + cssSelector);
return null;
}
return els.get(0);
}
示例14: execute
import org.jsoup.select.Elements; //导入方法依赖的package包/类
@Override
public void execute(Context context) throws MissingArgumentException {
if(!context.getChannel().isNSFW()) {
BotUtils.sendMessage(TextUtils.mustBeNSFW(context.getPrefix()), context.getChannel());
return;
}
LoadingMessage loadingMsg = new LoadingMessage("Loading image...", context.getChannel());
loadingMsg.send();
try {
Document doc = NetUtils.getDoc("https://www.suicidegirls.com/photos/sg/recent/all/");
Elements girls = doc.getElementsByTag("article");
Element girl = girls.get(ThreadLocalRandom.current().nextInt(girls.size()));
String name = girl.getElementsByTag("a").attr("href").split("/")[2].trim();
String imageUrl = girl.select("noscript").attr("data-retina");
String url = girl.getElementsByClass("facebook-share").attr("href");
EmbedBuilder embed = EmbedUtils.getDefaultEmbed()
.withAuthorName("SuicideGirls Image")
.withAuthorIcon("https://upload.wikimedia.org/wikipedia/commons/thumb/0/05/SuicideGirls_logo.svg/1280px-SuicideGirls_logo.svg.png")
.withUrl(url)
.appendDescription(String.format("Name: **%s**", StringUtils.capitalize(name)))
.withImage(imageUrl);
loadingMsg.edit(embed.build());
} catch (IOException err) {
loadingMsg.delete();
Utils.handle("getting SuicideGirls image", context, err);
}
}
示例15: getElementAtIndexOrNull
import org.jsoup.select.Elements; //导入方法依赖的package包/类
private Element getElementAtIndexOrNull(Element parent) {
Elements elements = selectChildren(parent);
int size = elements.size();
if (size == 0 || size <= index) {
return null;
}
return elements.get(index);
}