本文整理了Java中org.jsoup.nodes.Document.setBaseUri()
方法的一些代码示例,展示了Document.setBaseUri()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Document.setBaseUri()
方法的具体详情如下:
包路径:org.jsoup.nodes.Document
类名称:Document
方法名:setBaseUri
暂无
代码示例来源:origin: org.jsoup/jsoup
void maybeSetBaseUri(Element base) {
if (baseUriSetFromDoc) // only listen to the first <base href> in parse
return;
String href = base.absUrl("href");
if (href.length() != 0) { // ignore <base target> etc
baseUri = href;
baseUriSetFromDoc = true;
doc.setBaseUri(href); // set on the doc so doc.createElement(Tag) will get updated base, and to update all descendants
}
}
代码示例来源:origin: astamuse/asta4d
void maybeSetBaseUri(Element base) {
if (baseUriSetFromDoc) // only listen to the first <base href> in parse
return;
String href = base.absUrl("href");
if (href.length() != 0) { // ignore <base target> etc
baseUri = href;
baseUriSetFromDoc = true;
doc.setBaseUri(href); // set on the doc so doc.createElement(Tag) will get updated base, and to update all descendants
}
}
代码示例来源:origin: opacapp/opacclient
<I extends AccountItem> void loadPages(List<I> media, Document doc, Set<Integer> pagesLoaded,
ParseAccountListFunction<I> func) throws IOException {
Map<String, Integer> links = getAccountPageLinks(doc);
for (Map.Entry<String, Integer> link : links.entrySet()) {
if (!pagesLoaded.contains(link.getValue())) {
String html = httpGet(link.getKey(), ENCODING);
Document page = Jsoup.parse(html);
page.setBaseUri(link.getKey());
func.apply(media, page, link.getValue(), data);
pagesLoaded.add(link.getValue());
loadPages(media, page, pagesLoaded, func);
}
}
}
代码示例来源:origin: cn.edu.hfut.dmic.webcollector/WebCollector
public static void makeAbs(Document doc,String url){
if(url!=null){
doc.setBaseUri(url);
}
doc.traverse(new NodeVisitor() {
@Override
public void head(Node node, int i) {
if(node instanceof Element){
Element tag=(Element) node;
if(tag.hasAttr("href")){
String absHref=tag.attr("abs:href");
tag.attr("href",absHref);
}
if(tag.hasAttr("src")){
String absSrc=tag.attr("abs:src");
tag.attr("src",absSrc);
}
}
}
@Override
public void tail(Node node, int i) {
}
});
}
}
代码示例来源:origin: opacapp/opacclient
public String httpGet(String url, String encoding, boolean ignore_errors,
CookieStore cookieStore) throws
IOException {
String html = super.httpGet(url, encoding, ignore_errors, cookieStore);
if (html.contains("id=\"connect\"")) {
// British Library and Uni Duesburg-Essen do weird JavaScript redirects
Document doc = Jsoup.parse(html);
doc.setBaseUri(url);
return httpGet(doc.select("#connect a").first().attr("href").substring(6), encoding,
ignore_errors, cookieStore);
}
return html;
}
}
代码示例来源:origin: opacapp/opacclient
@Override
public DetailedItem getResultById(String id, String homebranch)
throws IOException, OpacErrorException {
try {
String url;
if (id.startsWith("https://") || id.startsWith("http://")) {
url = id;
} else {
url = opac_url + "/" + data.getJSONObject("urls").getString("simple_search") +
NO_MOBILE + "&id=" + id;
}
Document doc = Jsoup.parse(httpGet(url, getDefaultEncoding()));
doc.setBaseUri(url);
return parse_result(doc);
} catch (JSONException e) {
throw new IOException(e.getMessage());
}
}
代码示例来源:origin: opacapp/opacclient
@Override
public void start() throws IOException {
String html = httpGet(opac_url + "/search.cgi?art=f", ENCODING, false,
cookieStore);
Document doc = Jsoup.parse(html);
doc.setBaseUri(opac_url);
sessid = null;
for (Element link : doc.select("a")) {
String sid = getQueryParamsFirst(link.absUrl("href")).get("sess");
if (sid != null) {
sessid = sid;
break;
}
}
super.start();
}
代码示例来源:origin: opacapp/opacclient
String html = httpGet(url, getDefaultEncoding());
Document doc = Jsoup.parse(html);
doc.setBaseUri(url);
getDefaultEncoding());
detailsDoc = Jsoup.parse(detailsUrl);
detailsDoc.setBaseUri(detailsUrl);
代码示例来源:origin: opacapp/opacclient
private void loadMediaList(Document lentDoc, List<LentItem> items)
throws IOException {
items.addAll(parseMediaList(lentDoc));
String nextPageUrl = findNextPageUrl(lentDoc);
if (nextPageUrl != null) {
Document doc = Jsoup.parse(httpGet(nextPageUrl, getDefaultEncoding()));
doc.setBaseUri(lentDoc.baseUri());
loadMediaList(doc, items);
}
}
代码示例来源:origin: org.apache.marmotta/ldpath-functions-html
final Document jsoup = Jsoup.parse(string);
if (rdfBackend.isURI(context)) {
jsoup.setBaseUri(rdfBackend.stringValue(context));
代码示例来源:origin: opacapp/opacclient
static void parseResList(List<ReservedItem> media, Document doc, JSONObject data) {
if (doc.select("a[name=RES]").size() == 0) return;
Elements copytrs = doc.select("a[name=RES] ~ table:contains(Titel)").first().select("tr");
doc.setBaseUri(data.optString("baseurl"));
DateTimeFormatter fmt = DateTimeFormat.forPattern("dd.MM.yyyy").withLocale(Locale.GERMAN);
代码示例来源:origin: opacapp/opacclient
private void loadResList(Document resDoc, List<ReservedItem> items) throws IOException {
items.addAll(parseResList(resDoc));
String nextPageUrl = findNextPageUrl(resDoc);
if (nextPageUrl != null) {
Document doc = Jsoup.parse(httpGet(nextPageUrl, getDefaultEncoding()));
doc.setBaseUri(resDoc.baseUri());
loadResList(doc, items);
}
}
代码示例来源:origin: opacapp/opacclient
protected static void parse_reslist(String type,
List<ReservedItem> reservations, Document doc, int offset, JSONObject data) {
Elements copytrs = doc.select(".data tr");
doc.setBaseUri(data.optString("baseurl"));
int trs = copytrs.size();
if (trs == 1) {
代码示例来源:origin: opacapp/opacclient
@Override
public AccountData account(Account account) throws IOException,
JSONException, OpacErrorException {
Document startPage = login(account);
AccountData adata = new AccountData(account.getId());
if (startPage.select("#ctl00_ContentPlaceHolderMain_LabelCharges").size() > 0) {
String fees = startPage.select("#ctl00_ContentPlaceHolderMain_LabelCharges").text()
.replace("Kontostand:", "").trim();
if (!fees.equals("ausgeglichen")) adata.setPendingFees(fees);
}
String lentUrl = opac_url + "/user/borrow.aspx";
Document lentPage = Jsoup.parse(httpGet(lentUrl, getDefaultEncoding()));
lentPage.setBaseUri(lentUrl);
adata.setLent(parseMediaList(lentPage, data));
String resUrl = opac_url + "/user/reservations.aspx";
Document reservationsPage = Jsoup.parse(httpGet(resUrl, getDefaultEncoding()));
reservationsPage.setBaseUri(resUrl);
adata.setReservations(parseResList(reservationsPage, stringProvider, data));
return adata;
}
代码示例来源:origin: opacapp/opacclient
getDefaultEncoding());
Document doc = Jsoup.parse(html);
doc.setBaseUri(opac_url + "/APS_ZONES");
if (doc.select(".AccountSummaryCounterLink").size() > 0) {
return doc;
代码示例来源:origin: opacapp/opacclient
doc.setBaseUri(url);
return doc;
代码示例来源:origin: opacapp/opacclient
String lentHtml = httpGet(lentUrl, getDefaultEncoding());
Document lentDoc = Jsoup.parse(lentHtml);
lentDoc.setBaseUri(lentUrl);
loadMediaList(lentDoc, lentItems);
res.setLent(lentItems);
String resHtml = httpGet(resUrl, getDefaultEncoding());
Document resDoc = Jsoup.parse(resHtml);
resDoc.setBaseUri(resUrl);
loadResList(resDoc, reservedItems);
res.setReservations(reservedItems);
代码示例来源:origin: opacapp/opacclient
@Override
public String getPendingAccountFees(Account account)
throws IOException, JSONException, OpacErrorException {
start(); // TODO: Is this necessary?
if (!login(account)) {
return null;
}
String html = httpGet(opac_url
+ "/userAccount.do?methodToCall=showAccount&typ=1", ENCODING);
Document doc = Jsoup.parse(html);
doc.setBaseUri(opac_url);
AccountData res = new AccountData(account.getId());
parse_fees(doc, res);
return res.getPendingFees();
}
代码示例来源:origin: Kaysoro/KaellyBot
public static Resource getResource(Language lg, String url) throws IOException {
Document doc = JSoupManager.getDocument(url);
doc.setBaseUri(url);
String name = doc.getElementsByClass("ak-return-link").first().text();
String level = null;
代码示例来源:origin: opacapp/opacclient
@Test
public void testAccountPages() {
Document page1 = Jsoup.parse(readResource("/zones/medialist/koeln_pages_1.html"));
Document page2 = Jsoup.parse(readResource("/zones/medialist/koeln_pages_2.html"));
page1.setBaseUri(BASE_URL);
page2.setBaseUri(BASE_URL);
String nextPage1 = Zones.findNextPageUrl(page1);
assertNotNull(nextPage1);
assertEquals(nextPage1,
"https://katalog.stbib-koeln.de/alswww2" +
".dll/Obj_4051458325195?Style=Portal3&SubStyle=&Lang=GER&ResponseEncoding" +
"=utf-8&Method=PageDown&PageSize=10");
String nextPage2 = Zones.findNextPageUrl(page2);
assertNull(nextPage2);
}
}
内容来源于网络,如有侵权,请联系作者删除!