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


Java Elements.attr方法代码示例

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


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

示例1: getVidStreamingVideo

import org.jsoup.select.Elements; //导入方法依赖的package包/类
private String getVidStreamingVideo(String url) {
    String videoUrl = "";
    try {
        Document docdata = Jsoup.connect(url).userAgent(getUserAgent())
                .referrer("http://www.google.com")
                .timeout(Parser.getParseTimeOut()).get();
        Elements eles = docdata.select("div[class=videocontent]").select("video[id=my-video-player]").select("source");
        String tempUrl = "";
        if (eles != null && !eles.isEmpty()) {
            for (Element ele : eles) {
                tempUrl = ele.attr("abs:src");
                if (!TextUtils.isEmpty(tempUrl))
                    videoUrl = tempUrl;
            }
        } else {
            eles = docdata.select("div[class=videocontent]").select("iframe");
            if (eles != null && !eles.isEmpty()) {
                videoUrl = eles.attr("src");
                return getVideoFromProvider(videoUrl);
            }
        }
    } catch (IOException e) {
        WriteLog.appendLog(Log.getStackTraceString(e));
    }
    return videoUrl;
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:27,代码来源:Parser.java

示例2: rip

import org.jsoup.select.Elements; //导入方法依赖的package包/类
@Override
public void rip() throws IOException {
    logger.info("Retrieving " + this.url);
    Document doc = Http.url(url).get();
    Elements videos = doc.select("div.player-container > a");
    if (videos.size() == 0) {
        throw new IOException("Could not find Embed code at " + url);
    }
    String vidUrl = videos.attr("href");
    addURLToDownload(new URL(vidUrl), HOST + "_" + getGID(this.url));
    waitForThreads();
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:13,代码来源:XhamsterRipper.java

示例3: absPath

import org.jsoup.select.Elements; //导入方法依赖的package包/类
private String absPath(String input, String baseUrl) {
    Document doc = Jsoup.parse(input);
    //doc.getAllElements();
    //doc.head().prepend("<base href=" + baseUrl +"> </base>");
    Elements link = doc.select("link");
    link.attr("href", baseUrl + "/" + link.attr("href"));

    return doc.toString();
}
 
开发者ID:jsparber,项目名称:CaptivePortalAutologin,代码行数:10,代码来源:HttpServer.java

示例4: setData

import org.jsoup.select.Elements; //导入方法依赖的package包/类
private void setData(List<FictionModel> list, int eq, String type) {
    Elements select = document.select("div.blockcontent").eq(eq);
    Elements itemElements = select.select("li");
    list.add(getMoreTitle(type, select));
    FictionModel fictionModel;
    for (Element element : itemElements) {
        fictionModel = new FictionModel();
        Elements a = element.select("a");
        fictionModel.title = a.text();
        fictionModel.detailUrl = a.attr("abs:href");
        fictionModel.type = TYPE_ITEM;
        list.add(fictionModel);
    }
}
 
开发者ID:7449,项目名称:JsoupSample,代码行数:15,代码来源:JsoupPtFictionHomeManager.java

示例5: extractLink

import org.jsoup.select.Elements; //导入方法依赖的package包/类
public String extractLink(Element td) {
    Elements href = td.select("a");
    if (!href.isEmpty()) {
        //<i><a href="/wiki/1001_Spikes" title="1001 Spikes">1001 Spikes</a></i>
        return href.attr("href");
    }
    return null;
}
 
开发者ID:MannanM,项目名称:corporate-game-share,代码行数:9,代码来源:WikiElementTranslator.java

示例6: episodeSelect

import org.jsoup.select.Elements; //导入方法依赖的package包/类
/**
 * 웹툰별 에피소드 입력
 * 
 * @param webCode
 *            - 웹툰코드
 */
public void episodeSelect(String webCode) {
	try {

		Document document = Jsoup.connect("http://comic.naver.com/webtoon/list.nhn?titleId=" + webCode).get();
		Elements elements = document.select("ul.btn_group li").eq(1);
		String[] parseTag = elements.html().split("return");

		int index = parseTag[1].indexOf(")");
		String functionName = parseTag[1].substring(0, index);

		String firstEpisode = functionName.split(",")[1].replaceAll("'", "");
		sEp.setText(firstEpisode);

		elements = document.select("table.viewList > tbody > tr > td.title a").eq(0);
		String href = elements.attr("href");
		if ((!href.equals("")) || (href == null)) {
			String real_ep = href.split("no=")[1].split("&")[0];
			elements = document.select(".detail p");
			dEp.setText(real_ep);
		}

		sEp.setEditable(true);
		dEp.setEditable(true);

	} catch (Exception e) {
		e.printStackTrace();
	}

}
 
开发者ID:kimyearho,项目名称:WebtoonDownloadManager,代码行数:36,代码来源:NaverEventController.java

示例7: scrapeHtml

import org.jsoup.select.Elements; //导入方法依赖的package包/类
public static String scrapeHtml(String webHtml) {
    Document doc = Jsoup.parse(webHtml);
    Elements rssTag = doc.select("link[type='application/atom+xml']");

    String rssHref = rssTag.attr("href");
    return rssHref;
}
 
开发者ID:nitroignika,项目名称:duck-feed-2,代码行数:8,代码来源:SiteScrape.java

示例8: getAlbumTitle

import org.jsoup.select.Elements; //导入方法依赖的package包/类
public String getAlbumTitle(URL url) throws MalformedURLException {
    String gid = getGID(url);
    if (this.albumType == ALBUM_TYPE.ALBUM) {
        try {
            // Attempt to use album title as GID
            if (albumDoc == null) {
                albumDoc = Http.url(url).get();
            }

            Elements elems = null;

            /*
            // TODO: Add config option for including username in album title.
            // It's possible a lot of users would not be interested in that info.
            String user = null;
            elems = albumDoc.select(".post-account");
            if (elems.size() > 0) {
                Element postAccount = elems.get(0);
                if (postAccount != null) {
                    user = postAccount.text();
                }
            }
            */

            String title = null;
            final String defaultTitle1 = "Imgur: The most awesome images on the Internet";
            final String defaultTitle2 = "Imgur: The magic of the Internet";
            logger.info("Trying to get album title");
            elems = albumDoc.select("meta[property=og:title]");
            if (elems != null) {
                title = elems.attr("content");
                logger.debug("Title is " + title);
            }
            // This is here encase the album is unnamed, to prevent
            // Imgur: The most awesome images on the Internet from being added onto the album name
            if (title.contains(defaultTitle1) || title.contains(defaultTitle2)) {
                logger.debug("Album is untitled or imgur is returning the default title");
                // We set the title to "" here because if it's found in the next few attempts it will be changed
                // but if it's nto found there will be no reason to set it later
                title = "";
                logger.debug("Trying to use title tag to get title");
                elems = albumDoc.select("title");
                if (elems != null) {
                    if (elems.text().contains(defaultTitle1) || elems.text().contains(defaultTitle2)) {
                        logger.debug("Was unable to get album title or album was untitled");
                    }
                    else {
                        title = elems.text();
                    }
                }
            }

            String albumTitle = "imgur_";
            /*
            // TODO: Add config option (see above)
            if (user != null) {
                albumTitle += "user_" + user;
            }
            */
            albumTitle += gid;
            if (title != null) {
                albumTitle += "_" + title;
            }

            return albumTitle;
        } catch (IOException e) {
            // Fall back to default album naming convention
        }
    }
    return getHost() + "_" + gid;
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:72,代码来源:ImgurRipper.java

示例9: run

import org.jsoup.select.Elements; //导入方法依赖的package包/类
@Override
public void run() {
    Document doc;

    try {
        doc = get(mUrl);
    } catch (IOException e) {
        e.printStackTrace();
        failedOnUI(e.getMessage());
        return;
    }

    Elements topicDetailElements = doc.select("div.topic-detail");

    if (topicDetailElements.isEmpty()) {
        failedOnUI("找不到主题详情");
        return;
    }

    Elements elements = topicDetailElements.select("div.ui-header");

    if (elements.isEmpty()) {
        failedOnUI("找不到主题元信息");
        return;
    }

    TopicDetail topicDetail = new TopicDetail();

    Topic topic = GetTopicListTask.createTopicFromElement(elements.first());

    topicDetail.setTopic(topic);
    // 解析收藏
    Elements favouriteElement = doc.select(".J_topicFavorite");
    if(favouriteElement!=null){
        String hrefUrl = favouriteElement.attr("href");
        String dataType = favouriteElement.attr("data-type");
        String text = favouriteElement.text();
        Favorite favorite = new Favorite();
        favorite.setUrl(hrefUrl);
        favorite.setDataType(dataType);
        favorite.setText(text);
        topicDetail.setFavorite(favorite);
    }

    elements = topicDetailElements.select("div.ui-content");

    if (elements.isEmpty()) {
        failedOnUI("找不到主题内容");
        return;
    }

    topicDetail.setContent(elements.first().outerHtml());

    Elements commentsElements = doc.select("div.topic-reply");

    Map<Integer, Comment> comments = GetCommentsTask.getCommentsFromElements(commentsElements);

    topicDetail.setComments(comments);

    successOnUI(topicDetail);
}
 
开发者ID:mzlogin,项目名称:guanggoo-android,代码行数:62,代码来源:GetTopicDetailTask.java

示例10: getEpisodeVideo

import org.jsoup.select.Elements; //导入方法依赖的package包/类
@Override
public String getEpisodeVideo(String url) {
    String videoUrl = "";
    try {
        Document docdata = load(url, true);
        Elements videoEle = docdata.select("div[class=play-video]").select("iframe");
        if (videoEle != null && !videoEle.isEmpty()) {
            String tempUrl = videoEle.attr("abs:src");
            videoUrl = getVideoFromProvider(tempUrl);
            if (!TextUtils.isEmpty(videoUrl))
                return videoUrl;
        }
        Elements downloadEle = docdata.select("div[class=anime_video_body]")
                .select("div[class=download-anime]").select("a");
        if (downloadEle != null && !downloadEle.isEmpty()) {
            String downloadLink = downloadEle.get(0).attr("href");
            if (!TextUtils.isEmpty(downloadLink)) {
                videoUrl = getInternalVideoUrlAniUploader(downloadLink);
                if (!TextUtils.isEmpty(videoUrl)) {
                    return videoUrl;
                }
            }
        } else {
            Elements eles = docdata.select("div[id=video_container_div]").select("script");
            if (eles != null && !eles.isEmpty()) {
                Element playerScript = eles.last();
                if (playerScript != null) {
                    String scriptText[] = playerScript.html().split("\n");
                    if (scriptText != null && scriptText.length > 0) {
                        for (int i = 0; i < scriptText.length; i++) {
                            if (scriptText[i].contains("file:")) {
                                videoUrl = scriptText[i].trim().replace("file: '", "").replace("',", "");
                                break;
                            }
                        }
                    }
                }
                //videoUrl = eles.select("video").select("source").attr("abs:src");
            } else {
                eles = docdata.select("iframe[class=mirrorVid]");
                if (eles != null && !eles.isEmpty()) {
                    videoUrl = eles.attr("src");
                    if (!TextUtils.isEmpty(videoUrl))
                        videoUrl = getVideoFromProvider(videoUrl);
                }
            }
        }
    } catch (IOException e) {
        WriteLog.appendLog(Log.getStackTraceString(e));
    }
    return videoUrl;
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:53,代码来源:GoGoAnime.java

示例11: parseTutorias

import org.jsoup.select.Elements; //导入方法依赖的package包/类
public List<TutoriaData> parseTutorias(boolean isNew, String text, SubjectData subject) {
    List<TutoriaData> tutorias = new ArrayList<>();
    try {
        JSONObject jdata = new JSONObject(text);
        if (jdata.has("aaData")) {
            JSONArray jarray = jdata.getJSONArray("aaData");
            for (int i = 0; i < jarray.length(); i++) {
                TutoriaData tutoria = new TutoriaData();
                JSONArray jtutoria = jarray.getJSONArray(i);
                String name;
                String state;
                String html;
                String id;
                if (isNew) {
                    name = jtutoria.getString(0);
                    state = "";
                    html = jtutoria.getString(3);
                    id = jtutoria.getString(4);
                } else {
                    name = jtutoria.getString(0);
                    state = jtutoria.getString(3);
                    if (state.contains("pendiente")) {
                        state = context.getString(R.string.tutoria_without_answer);
                    }
                    html = jtutoria.getString(4);
                    id = jtutoria.getString(5);
                }
                Document doc = Jsoup.parse(html);
                Elements elements = doc.select("img");
                String user = elements.attr("title");
                String src = elements.attr("src");

                String sname = AppManager.after(subject.getName(), parseYear() + " ");
                sname = AppManager.before(sname, "(" + subject.getId());

                tutoria.setSubject(subject.getId());
                tutoria.setSubjectName(sname);
                tutoria.setTitle(name);
                tutoria.setId(id);
                tutoria.setLastModify(state);
                tutoria.setTeacherName(user);
                tutoria.setTeacherPicture(src);
                tutorias.add(tutoria);
            }
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return tutorias;
}
 
开发者ID:Onelio,项目名称:ConnectU,代码行数:51,代码来源:TutoriasRequest.java


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