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


Java Document类代码示例

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


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

示例1: getWebtoon

import org.jsoup.nodes.Document; //导入依赖的package包/类
/**
 * 웹툰조회
 */
public void getWebtoon(String code) {

	if (!"".equals(code)) {
		CommonService cs = new CommonService();

		Connection conn = cs.getConnection(code);
		conn.timeout(5000);

		Document doc = null;
		
		codeInputField.setText(code);
		wDesc.setWrapText(true);

		try {

			doc = conn.get();

			String title = doc.select("title").text().split("::")[0];
			setTitle(title);

			String author = doc.select("div.detail h2 > span").text();
			wTitle.setText(title + "(" + author + ")");

			String desc = doc.select("div.detail p").text();
			wDesc.setText(desc);

			String img = doc.select("div.thumb > a img").attr("src");
			thumbnail.setImage(new Image(img, true));

		} catch (Exception e) {
			e.printStackTrace();
		}
	} else {
		Platform.runLater(new Runnable() {
			@Override
			public void run() {
				AlertSupport alert = new AlertSupport("웹툰코드를 입력하세요.");
				alert.alertInfoMsg(stage);
			}
		});
	}
}
 
开发者ID:kimyearho,项目名称:WebtoonDownloadManager,代码行数:46,代码来源:ManualController.java

示例2: meiyuxsCatalog

import org.jsoup.nodes.Document; //导入依赖的package包/类
private static Map meiyuxsCatalog(Map map, String url) {
  try {
    List data = new ArrayList();
    Document document = Jsoup
        .connect(url)
        .userAgent(FormatUtil.USER_AGENT_PC)
        .get();
    Element body = document.body();
    Elements catalogEles = body.getElementsByClass("list-group-item");
    for (Element catalogE : catalogEles) {
      if (catalogE.getElementsByTag("a").size() > 0) {
        Map<String, Object> _map = new HashMap<>();
        _map.put("catalog", catalogE.text());
        _map.put("href", "http://www.meiyuxs.com" + catalogE.getElementsByTag("a").first().attr("href"));
        data.add(_map);
      }
    }
    map.put("data", data);
    map.put("cover", "");
    map.put("lastChapter", ((Map) data.get(data.size() - 1)).get("catalog").toString());
  } catch (IOException e) {
    e.printStackTrace();
  }
  return map;
}
 
开发者ID:tomoya92,项目名称:android-apps,代码行数:26,代码来源:JsoupUtil.java

示例3: 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"));

    String sTitle = "";
    Elements title = document.select("#header h1");
    if (title.size() > 0)
        sTitle = title.get(0).text();

    List<String> tagList = new ArrayList<>();
    Elements tags = document.select("ul.tagList a");
    if (tags.size() > 0)
        for (Element tag : tags)
            tagList.add(tag.text());

    Elements elements = document.select("ul.gallery li:has(img)");
    for (Element element : elements) {
        urls.add(new PicInfo(element.attr("data-src")).setTitle(sTitle).setTags(tagList));
    }

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

示例4: showWord

import org.jsoup.nodes.Document; //导入依赖的package包/类
public void showWord() {
    try {
        String language;
        Languages l;
        l = (Languages) cmbLanguage.getSelectedItem();
        language = l.getLang();
        Document doc = Jsoup.connect("http://evilinsult.com/generate_insult.php?lang=" + language).get();
        Elements links = doc.select("body");
        for (Element link : links) {
            txtPaneShow.setText("\n" + link.text());
        }
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception ex) {
        txtPaneShow.setText("\n" + "Insult Outage! Please Check Your Internet Connection And Try Again In Three Minutes");
    }
}
 
开发者ID:EvilInsultGenerator,项目名称:desktop,代码行数:18,代码来源:Main.java

示例5: onHandleParseHTML

import org.jsoup.nodes.Document; //导入依赖的package包/类
@Override
public void onHandleParseHTML(final String url) {
    mView.showLoading(true);
    Observable.create(new ObservableOnSubscribe<ArrayList<ArticleItem>>() {
        @Override
        public void subscribe(ObservableEmitter<ArrayList<ArticleItem>> e) throws Exception {
            ArrayList<ArticleItem> list = new ArrayList<>();
            Document doc = Jsoup.connect(url).get();
            Elements ul = doc.getElementsByClass("list_line");
            for (Element u : ul) {
                Elements li = u.getElementsByTag("li");
                for (Element l : li) {
                    String text = l.getElementsByTag("a").text();
                    String href = l.getElementsByTag("a").attr("href");
                    String time = l.getElementsByTag("span").text();
                    list.add(new ArticleItem(text, href, time));
                }
            }
            e.onNext(list);
        }
    })
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Consumer<ArrayList<ArticleItem>>() {
                @Override
                public void accept(@NonNull ArrayList<ArticleItem> articleItems) throws Exception {
                    mView.showList(articleItems);
                    mView.showLoading(false);
                }
            });
}
 
开发者ID:InnoFang,项目名称:PartyBuildingStudies,代码行数:32,代码来源:NewsPresenter.java

示例6: parseToText

import org.jsoup.nodes.Document; //导入依赖的package包/类
@JSStaticFunction
public static void parseToText(final String url, final String option, final Function func) throws IOException {
    new Thread(new Runnable() {
        @Override
        public void run() {
            Document document = null;
            try {
                document = Jsoup.connect(url).get();
                Elements element = document.select(option);

                func.call(context, scope, scope, new Object[] { element.text(), null });
            } catch (IOException e) {
                try {
                    func.call(context, scope, scope, new Object[] { null, e });
                } catch (Exception err) {}
            }
        }
    }).start();
}
 
开发者ID:Su-Yong,项目名称:NewKakaoBot,代码行数:20,代码来源:ScriptUtil.java

示例7: getURLsFromPage

import org.jsoup.nodes.Document; //导入依赖的package包/类
@Override
public List<String> getURLsFromPage(Document doc) {
    List<String> result = new ArrayList<>();
    for (Element thumb : doc.select("div.picture_view > div.pictures_block > div.items > div.item-container > a > div.thumb_container > div.img > img")) {
        String image = thumb.attr("src");
        // replace thumbnail urls with the urls to the full sized images
        image = image.replaceAll(
                "https://upt.xhcdn\\.",
                "http://up.xhamster.");
        image = image.replaceAll("ept\\.xhcdn", "ep.xhamster");
        image = image.replaceAll(
                "_160\\.",
                "_1000.");
        // Xhamster has bad cert management and uses invalid certs for some cdns, so we change all our requests to http
        image = image.replaceAll("https", "http");
        result.add(image);
    }
    return result;
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:20,代码来源:XhamsterRipper.java

示例8: getDocumentWithCookie

import org.jsoup.nodes.Document; //导入依赖的package包/类
/**
 * 方法说明:绑定单cookie模拟浏览器,返回document对象
 * 
 * @param url           被访问url
 * @param cookieKey     绑定cookie的key
 * @param cookieValue   绑定cookie的value
 * @return Document     返回document对象
 * @throws Exception
 */
public static Document getDocumentWithCookie(String url, String cookieKey, String cookieValue) throws Exception {

    Document doc = null;

    if (StringUtil.isEmpty(cookieKey) && StringUtil.isEmpty(cookieValue)) {
        doc = getDocument(url);
    } else if (!StringUtil.isEmpty(cookieKey) && !StringUtil.isEmpty(cookieValue)){
        Map<String, String> cookiesMap = new HashMap<String, String>();
        cookiesMap.put(cookieKey, cookieValue);
        doc = getDocumentWithCookies(url, cookiesMap);
    } else {
        // parameter is error. 参数が不正である、所传参数错误。
        throw new IllegalArgumentException("key or value is err"); // TODO hard coding is fixing bluetata 2017/03/20 add
    }
    return doc;
}
 
开发者ID:bluetata,项目名称:crawler-jsoup-maven,代码行数:26,代码来源:JsoupUtil.java

示例9: extractFromProperties

import org.jsoup.nodes.Document; //导入依赖的package包/类
public static List<MatchedDate> extractFromProperties(Document document) {
    List<MatchedDate> result = Lists.newArrayList();

    for (String selector : ITEMPROP_SELECTORS) {
        document.select(selector).forEach(m -> {
            String datetime = m.attr("datetime");
            String content = m.attr("content");
            String title = m.attr("title");
            if (!Strings.isNullOrEmpty(datetime)) {
                result.add(new MatchedDate(datetime, selector));
            } else if (!Strings.isNullOrEmpty(content)) {
                result.add(new MatchedDate(content, selector));
            } else if (!Strings.isNullOrEmpty(title)) {
                result.add(new MatchedDate(title, selector));
            }
        });
    }

    return result;
}
 
开发者ID:tokenmill,项目名称:crawling-framework,代码行数:21,代码来源:DateParser.java

示例10: getContent

import org.jsoup.nodes.Document; //导入依赖的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, "utf-8"));
    Elements elements = document.select("div.album");
    for (Element element : elements) {
        AlbumInfo temp = new AlbumInfo();

        Elements title = element.select("span.name");
        if (title.size() > 0)
            temp.setTitle(title.get(0).text());

        Elements album = element.select(".pic_box a");
        temp.setAlbumUrl(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;
}
 
开发者ID:lanyuanxiaoyao,项目名称:PicKing,代码行数:24,代码来源:XiuMM.java

示例11: Wikipedia

import org.jsoup.nodes.Document; //导入依赖的package包/类
static void Wikipedia(String dico) {
    Document significatowikipedia = null;
    String cercowikipedia = dico.substring((dico.indexOf("'")) + 1, (dico.lastIndexOf("'")));
    try {
        significatowikipedia = Jsoup.connect("https://it.wikipedia.org/wiki/" + cercowikipedia.replace(" ", "_")).userAgent("Mozilla").get();
        String divs = significatowikipedia.select("p").text();
        if (!divs.equals("")) {
            new GUI().giveResponse("La ricerca di " + cercowikipedia + " su wikipedia ha restituito il seguente risultato:" + '\n' + divs);
        } else {
            new GUI().giveResponse("Mi dispiace, non ho trovato informazioni su " + cercowikipedia + " su Wikipedia...");
        }
    } catch (HttpStatusException e) {
        new GUI().giveResponse("Mi dispiace, Wikipedia sembra non avere una voce per '" + cercowikipedia +"'...");
    } catch (java.io.IOException f) {
        f.printStackTrace();
    } catch (StringIndexOutOfBoundsException g) {
        new GUI().giveResponse("Ricorda che, perché io cerchi informazioni riguardo a qualcosa, occorre che tu la definisca fra due virgolette!");
    }
}
 
开发者ID:emiliodallatorre,项目名称:Linda-AI,代码行数:20,代码来源:Act.java

示例12: testJsoupSelectorUnexpectedError

import org.jsoup.nodes.Document; //导入依赖的package包/类
/**
 * Test that {@link PawpedsDocumentParser#parseSearch(Document)} throws an
 * {@link IllegalArgumentException} if there is an jsoup parsing error.
 */
@Test(expected = IllegalArgumentException.class)
public void testJsoupSelectorUnexpectedError() throws Exception {
	// Given
	Document document = mock(Document.class);

	Elements noErrorElement = mock(Elements.class);
	when(noErrorElement.text()).thenReturn("");
	when(document.select("th.error")).thenReturn(noErrorElement);

	when(document.select("table.searchresult tr.searchresult:has(td.searchresult)")).thenThrow(SelectorParseException.class);

	// When
	pawpedsDocumentParser.parseSearch(document);

	// Then
	// the exception is expected
}
 
开发者ID:padriano,项目名称:catpeds,代码行数:22,代码来源:PawpedsDocumentParserTest.java

示例13: loadAnuncios

import org.jsoup.nodes.Document; //导入依赖的package包/类
public void loadAnuncios(final AnunciosCallback callback) {
    UAWebService.HttpWebGetRequest(context, ANUNCIOS_URL, new UAWebService.WebCallBack() {
        @Override
        public void onNavigationComplete(boolean isSuccessful, String body) {
            if (isSuccessful) {
                Document doc = Jsoup.parse(body);
                //Get Post data
                Element anuncios = doc.select(ANUNCIOS_LIST_BODY).first();
                try {
                    for (Element anuncio : anuncios.children()) {
                        parseAnuncio(anuncio, "");
                    }
                    callback.onResult(true, "");
                } catch (NullPointerException e) {
                    FirebaseCrash.log(body);
                    FirebaseCrash.report(e);
                    callback.onResult(false, ErrorManager.LOGIN_REJECTED); //Usually because session ended!
                }
            } else {
                callback.onResult(false, body);
            }
        }
    });
}
 
开发者ID:Onelio,项目名称:ConnectU,代码行数:25,代码来源:AnunciosRequest.java

示例14: getT

import org.jsoup.nodes.Document; //导入依赖的package包/类
@Override
public List<ImageModel> getT(Document document) {
    if (view == null) {
        return new ArrayList<>();
    }
    switch (view.getType()) {
        case ApiConfig.Type.DOU_BAN_MEI_ZI:
            return JsoupDoubanManager.get(document).getImageList();
        case ApiConfig.Type.KK:
            return JsoupKKManager.get(document).getImageList();
        case ApiConfig.Type.M_ZI_TU:
            return JsoupMZiTuManager.get(document).getImageList();
        case ApiConfig.Type.MM:
            return JsoupMMManager.get(document).getImageList();
        case ApiConfig.Type.MEIZITU:
            return JsoupMeiZiTuManager.get(document).getImageList();
        default:
            return new ArrayList<>();
    }
}
 
开发者ID:7449,项目名称:JsoupSample,代码行数:21,代码来源:ImageListPresenterImpl.java

示例15: getDescriptionsFromPage

import org.jsoup.nodes.Document; //导入依赖的package包/类
@Override
public List<String> getDescriptionsFromPage(Document page) {
    List<String> textURLs = new ArrayList<>();
    // Iterate over all thumbnails
    for (Element thumb : page.select("div.zones-container span.thumb")) {
        logger.info(thumb.attr("href"));
        if (isStopped()) {
            break;
        }
        Element img = thumb.select("img").get(0);
        if (img.attr("transparent").equals("false")) {
            continue; // a.thumbs to other albums are invisible
        }
        textURLs.add(thumb.attr("href"));

    }
    return textURLs;
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:19,代码来源:DeviantartRipper.java


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