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


Java Document.select方法代码示例

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


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

示例1: getDetailContent

import org.jsoup.nodes.Document; //导入方法依赖的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"));
    PicInfo picInfo = new PicInfo();
    Elements elements = document.select("#bigpic img");
    for (Element element : elements) {
        picInfo.setPicUrl(baseUrl + element.attr("src"));
    }
    Elements title = document.select("#entry h1");
    if (title.size() > 0)
        picInfo.setTitle(title.text());
    Elements tags = document.select(".postinfo a");
    if (tags.size() > 0) {
        List<String> tagList = new ArrayList<>();
        for (Element t : tags)
            tagList.add(t.text());
        picInfo.setTags(tagList);
    }
    urls.add(picInfo);

    resultMap.put(DetailActivity.parameter.CURRENT_URL, currentUrl);
    resultMap.put(DetailActivity.parameter.RESULT, urls);
    return resultMap;
}
 
开发者ID:lanyuanxiaoyao,项目名称:PicKing,代码行数:26,代码来源:Mntu92.java

示例2: getDetailContent

import org.jsoup.nodes.Document; //导入方法依赖的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 title = document.select("h2.main-title");
    String sTitle = "";
    if (title.size() > 0)
        sTitle = title.get(0).text();

    Elements time = document.select("div.main-header span.post-span");
    String sTime = "";
    if (time.size() > 0)
        sTime = time.get(0).text();

    Elements elements = document.select(".main-body a:has(img)");
    for (Element element : elements) {
        urls.add(new PicInfo(element.attr("href")).setTitle(sTitle).setTime(sTime));
    }
    resultMap.put(DetailActivity.parameter.CURRENT_URL, currentUrl);
    resultMap.put(DetailActivity.parameter.RESULT, urls);
    return resultMap;
}
 
开发者ID:lanyuanxiaoyao,项目名称:PicKing,代码行数:24,代码来源:JDlingyu.java

示例3: testDriver

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
@Test
public void testDriver() throws IOException {
    WebDriver driver = new RemoteWebDriver(toUrl("http://localhost:9515"), DesiredCapabilities.chrome());
    driver.get(URL2);

    String response = driver.getPageSource();
    Document doc = Jsoup.connect(URL2).ignoreContentType(true).get();
    Elements scriptTags = doc.select("body");

    // get All functions


    try {
        String result = (String) engine.eval(response);
    } catch (ScriptException e) {
        e.printStackTrace();
    }

    log.info("PageSource " + response);

    driver.quit();
}
 
开发者ID:robevansuk,项目名称:delay-repay-bot,代码行数:23,代码来源:PhantomJSTest.java

示例4: getMP4UploadVideo

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
public String getMP4UploadVideo(String url) {
    String lVideoUrl = "";
    try {
        Document docdata = Jsoup.connect(url).userAgent(mUserAgent)
                .referrer("http://www.google.com")
                .timeout(Parser.getParseTimeOut()).get();
        Elements eles = docdata.select("script + script");
        if (eles != null && !eles.isEmpty()) {
            lVideoUrl = eles.get(eles.size() - 2).html();
            if (!TextUtils.isEmpty(lVideoUrl)) {
                final Pattern pattern = Pattern.compile("'file': '(.+?)'");
                final Matcher matcher = pattern.matcher(lVideoUrl);
                matcher.find();
                lVideoUrl = matcher.group(1);
            }
        }
    } catch (IOException e) {
        WriteLog.appendLog(Log.getStackTraceString(e));
    }
    return lVideoUrl;
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:22,代码来源:Parser.java

示例5: getServerInfo

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
/**
 * Retrieves information about the <code>server</code> not essential for Source/RCON socket creation but for associated
 * services like an FTP server operating for the server's location.
 *
 * @param subId the internal id GameServers uses for its servers
 * @return a map with configuration key-values found in the GS web page
 * @throws IOException if the web operation could not be completed
 */
@Retryable(backoff = @Backoff(2000L))
public Map<String, String> getServerInfo(String subId) throws IOException {
    Map<String, String> map = new HashMap<>();
    Document document = validate(getPanelView(subId, "server_information"));
    Result result = extractResult(document.select("td.content_main").text());
    if (result != Result.OTHER) {
        map.put("error", result.toString());
    }
    Elements infos = document.select("div.server_info > a");
    String surl = infos.first().text();
    if (surl.startsWith("ftp://")) {
        URL url = new URL(surl);
        map.put("ftp-hostname", url.getHost());
        String[] userInfo = Optional.ofNullable(url.getUserInfo()).orElse("").split(":");
        if (userInfo.length == 2) {
            map.put("ftp-username", userInfo[0]);
            map.put("ftp-password", userInfo[1]);
        }
    }
    return map;
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:30,代码来源:GameAdminService.java

示例6: action

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
public void action(JSONObject data) throws EventException {
	final JSONObject article = data.optJSONObject(Article.ARTICLE);

	String content = article.optString(Article.ARTICLE_CONTENT);

	final Document doc = Jsoup.parse(content, StringUtils.EMPTY, Parser.htmlParser());
	doc.outputSettings().prettyPrint(false);

	final StringBuilder listBuilder = new StringBuilder();

	listBuilder.append("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + Latkes.getStaticServePath()
			+ "/plugins/list/style.css\" />");

	final Elements hs = doc.select("h1, h2, h3, h4, h5");

	listBuilder.append("<ul class='b3-solo-list'>");
	for (int i = 0; i < hs.size(); i++) {
		final Element element = hs.get(i);
		final String tagName = element.tagName().toLowerCase();
		final String text = element.text();
		final String id = "b3_solo_" + tagName + "_" + i;

		element.before("<span id='" + id + "'></span>");

		listBuilder.append("<li class='b3-solo-list-").append(tagName).append("'><a href='#").append(id)
				.append("'>").append(text).append("</a></li>");
	}
	listBuilder.append("</ul>");

	final Element body = doc.getElementsByTag("body").get(0);

	content = listBuilder.toString() + body.html();

	article.put(Article.ARTICLE_CONTENT, content);
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:36,代码来源:ArticleController.java

示例7: verifyZhihuImportance

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
public boolean verifyZhihuImportance(@NotNull @NonNls String username) {
	try {
		IntTokenizer tokenizer = null;
		Document page = Jsoup.parse(
				new URL(String.format(ZhihuApiRoot,username)),
				5000
		);
		Elements root = page.select("div[class='meta']");
		tokenizer = IntTokenizer.of(root.text());
		int reputationPoint = tokenizer.nextToken();
		tokenizer.nextToken();
		int likesPoint = tokenizer.nextToken();
		return (reputationPoint >= 50 && likesPoint >= 40);
	} catch (IOException e) {
		throw new RuntimeException("unable to fetch data from zhihu", e);
	}
}
 
开发者ID:ProgramLeague,项目名称:strictfp-back-end,代码行数:18,代码来源:VerifyAccount.java

示例8: getURLsFromPage

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
@Override
public List<String> getURLsFromPage(Document doc) {
    List<String> result = new ArrayList<>();
    for (Element el : doc.select("meta[property=og:image]")) {
        String imageSource = el.attr("content");
        imageSource = imageSource.replace(" alt=", "");
        result.add(imageSource);
    }
    return result;
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:11,代码来源:SinnercomicsRipper.java

示例9: getSingleQueryResult

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
private static String getSingleQueryResult(Document soup, String query, boolean toString){
    Elements re = soup.select(query);
    if(!re.isEmpty()){
        if(toString){
            return re.get(0).toString();
        }else {
            return re.get(0).text();
        }
    }else{
        return "";
    }
}
 
开发者ID:mmjang,项目名称:ankihelper,代码行数:13,代码来源:VocabCom.java

示例10: getURLsFromPage

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
@Override
public List<String> getURLsFromPage(Document page) {
    List<String> result = new ArrayList<>();
    for (Element el : page.select("a.photoThumb")) {
        result.add(el.attr("href"));
    }
    return result;
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:9,代码来源:RajceRipper.java

示例11: getNextPage

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
@Override
public Document getNextPage(Document doc) throws IOException {
    // Find next page
    Elements hrefs = doc.select("a.next");
    if (hrefs.size() == 0) {
        throw new IOException("No more pages");
    }
    String nextUrl = "http://www.bcfakes.com" + hrefs.first().attr("href");
    sleep(500);
    return Http.url(nextUrl).get();
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:12,代码来源:BcfakesRipper.java

示例12: wordLookup

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
public List<Definition> wordLookup(String key) {
    try {
        Document doc = Jsoup.connect(wordUrl + key)
                .userAgent("Mozilla")
                .timeout(5000)
                .get();
        String headWord = getSingleQueryResult(doc, "h1.dynamictext", false);
        String defShort = getSingleQueryResult(doc, "p.short", true).replace("<i>","<b>").replace("</i>","</b>");
        String defLong = getSingleQueryResult(doc, "p.long", true).replace("<i>","<b>").replace("</i>","</b>");
        Elements mp3Soup = doc.select("a.audio");
        String mp3Id = "";
        if(mp3Soup.size() > 0){
            mp3Id = mp3Soup.get(0).attr("data-audio");
        }

        List<Definition> definitionList = new ArrayList<>();

        if(headWord.isEmpty()){
            return definitionList;
        }
        if(!defShort.isEmpty()){
            HashMap<String, String> eleMap = new HashMap<>();
            eleMap.put(EXP_ELE[0], headWord);
            eleMap.put(EXP_ELE[1], getMp3Url(mp3Id));
            eleMap.put(EXP_ELE[2], defShort.replaceAll("<p .+?>","").replaceAll("</p>",""));
            definitionList.add(new Definition(eleMap, defShort));
        }

        return definitionList;

    } catch (IOException ioe) {
        //Log.d("time out", Log.getStackTraceString(ioe));
        Toast.makeText(MyApplication.getContext(), Log.getStackTraceString(ioe), Toast.LENGTH_SHORT).show();
        return new ArrayList<Definition>();
    }

}
 
开发者ID:mmjang,项目名称:quiz_helper,代码行数:38,代码来源:VocabCom.java

示例13: getURLsFromPage

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
@Override
public List<String> getURLsFromPage(Document doc) {
    List<String> imageURLs = new ArrayList<>();
    for (Element thumb : doc.select("div#galleria > a > img")) {
        String image = thumb.attr("src");
        imageURLs.add(image);
    }
    return imageURLs;
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:10,代码来源:YuvutuRipper.java

示例14: fetch

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
public void fetch() throws IOException {
    Document document = Jsoup.connect(SAKURA_SPEED_URL).get();
    Elements tables = document.select("table");
    Elements fonts = document.select("b>font[color=red]");
    for (int i = 0; i < tables.size(); i++) {
        updateDiscList(tables.get(i), fonts.get(i).text());
    }
}
 
开发者ID:mingzuozhibi,项目名称:mzzb-server,代码行数:9,代码来源:SakuraSpeedSpider.java

示例15: getSingleQueryResult

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
private static String getSingleQueryResult(Document soup, String query, boolean toString){
    Elements re = soup.select(query);
    if(!re.isEmpty()){
        if(toString){
            return re.get(0).toString();
        }else {
            return re.get(0).text().trim();
        }
    }else{
        return "";
    }
}
 
开发者ID:mmjang,项目名称:ankihelper,代码行数:13,代码来源:WebsterLearners.java


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