org.jsoup.Connection.parser()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中org.jsoup.Connection.parser()方法的一些代码示例,展示了Connection.parser()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Connection.parser()方法的具体详情如下:
包路径:org.jsoup.Connection
类名称:Connection
方法名:parser

Connection.parser介绍

[英]Provide an alternate parser to use when parsing the response to a Document. If not set, defaults to the HTML parser, unless the response content-type is XML, in which case the XML parser is used.
[中]提供在解析文档响应时使用的备用解析器。如果未设置,则默认为HTML解析器,除非响应内容类型为XML,在这种情况下使用XML解析器。

代码示例

代码示例来源:origin: crazyhitty/Munch

@Override
protected String doInBackground(String... strings) {
  Document opmlDocument = null;
  try {
    if (mUrl != null) {
      opmlDocument = Jsoup.connect(mUrl).parser(Parser.xmlParser()).get();
    } else {
      opmlDocument = Jsoup.parse(mFile, "UTF-8");
    }
  } catch (IOException e) {
    e.printStackTrace();
    return e.getMessage();
  }
  if (opmlDocument != null) {
    mOpmlItems = opmlDocument.select("outline");
  }
  return "success";
}

代码示例来源:origin: crazyhitty/Munch

@Override
protected String doInBackground(String... strings) {
  try {
    Document rssDocument = Jsoup.connect(mUrl).ignoreContentType(true).parser(Parser.xmlParser()).get();
    mItems = rssDocument.select("item");
  } catch (IOException e) {
    e.printStackTrace();
    return "failure";
  }
  return "success";
}

代码示例来源:origin: abc9070410/JComicDownloader

org.jsoup.nodes.Document doc = org.jsoup.Jsoup.connect(urlString.replaceFirst("[.]com[/]manhua-", ".com/rss-")).cookie("Cookie", "isAdult=1").parser(org.jsoup.parser.Parser.xmlParser()).get();
this.title = Common.getStringRemovedIllegalChar(NewEncoding.StoT(doc.getElementsByTag("title").get(0).text()));
for  (org.jsoup.nodes.Element e : doc.getElementsByTag("item")){

相关文章