2 Star 3 Fork 2

chaiyansheng / JsoupDemo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

JsoupDemo

介绍

Java的Jsoup学习,参考博客和教程,下载图片和小说

一、Java的JSoup

0、Idea创建Maven项目

File->New->Project...->Maven...

1、引入JSoup支持

<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
    <groupId>org.jsoup</groupId>
    <artifactId>jsoup</artifactId>
    <version>1.12.1</version>
</dependency>

2、连接

package cays.jsoup;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import java.io.IOException;

/**
 * 第一个JSoup程序
 *
 * @author Chai yansheng
 * @create 2019-08-16 9:27
 **/
public class FirstJSoupExample {
    /**
     * 连接百度输出网站名称
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        Document document = Jsoup.connect("https://www.baidu.com").get();
        String title = document.title();
        System.out.println("title : " + title);
    }
}

3、Jsoup入门

Jsoup是用于解析HTML,就类似XML解析器用于解析XMLJsoup它解析HTML成为真实世界的HTML。 它与jquery选择器的语法非常相似,并且非常灵活容易使用以获得所需的结果。

1、能用Jsoup实现什么?

  • URL,文件或字符串中刮取并解析HTML
  • 查找和提取数据,使用DOM遍历或CSS选择器
  • 操纵HTML元素,属性和文本
  • 根据安全的白名单清理用户提交的内容,以防止XSS攻击
  • 输出整洁的HTML

2、JSoup应用的主要类

org.jsoup.Jsoup

Jsoup类是任何Jsoup程序的入口点,并将提供从各种来源加载和解析HTML文档的方法。

Jsoup类的一些重要方法:

方法 描述
static Connection connect(String url) 创建并返回URL的连接。
static Document parse(File in, String charsetName) 将指定的字符集文件解析成文档。
static Document parse(String html) 将给定的html代码解析成文档。
static String clean(String bodyHtml, Whitelist whitelist) 从输入HTML返回安全的HTML,通过解析输入HTML并通过允许的标签和属性的白名单进行过滤。

org.jsoup.nodes.Document

该类表示通过Jsoup库加载HTML文档。可以使用此类执行适用于整个HTML文档的操作。

org.jsoup.nodes.Element

HTML元素是由标签名称,属性和子节点组成。 使用Element类,您可以提取数据,遍历节点和操作HTML

3、应用实例

一些使用Jsoup API处理HTML文档的例子。

载入文件

从URL加载文档,使用Jsoup.connect()方法从URL加载HTML

    /**
     * 从URL加载文档,使用Jsoup.connect()方法从URL加载HTML。
     * @param url
     * @return
     */
    public Document getDocumentFromUrl(String url) {
        Document document = null;
        try {
            document = Jsoup.connect(url).get();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return document;
    }

从文件加载文档

使用Jsoup.parse()方法从文件加载HTML。

    /**
     * 从Html文件解析Document
     * @param path 文件路径
     * @param encode 文件编码方式
     * @return
     */
    public Document getDocumentFromHtml(String path, String encode) {
        Document document = null;
        try {
            document = Jsoup.parse(new File(path), encode);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return document;
    }

从String加载文档

使用Jsoup.parse()方法从字符串加载HTML。

    /**
     * 从string中解析document
     * @param html
     * @return
     */
    public Document getDocumentFromString(String html) {
         return Jsoup.parse(html);
    }

4、获取Fav图标

    /**
     * 获取fav图标
     * @param url
     */
    public void getFavImg(String url) {
        String favImage = "Not Found!";
        Document document = getDocumentFromUrl(url);
        Element element = document.head().select("link[href~=.*\\.(ico|png)]").first();
        if (element == null) {
            element = document.head().select("meta[itemprop=image]").first();
            if (element != null) {
                favImage = element.attr("content");
            }
        } else {
            favImage = element.attr("href");
        }
        System.out.println(favImage);
    }

5、获取网站所有链接

    /**
     * 获取网站所有连接
     * @param url
     */
    public void getAllUrls(String url) {
        Document document = getDocumentFromUrl(url);
        Elements links = document.select("a[href]");
        for (Element link : links) {
            System.out.println("link : " + link.attr("href"));
            System.out.println("text : " + link.text());
        }
    }

6、获取HTML页面中的所有图像

    /**
     * 获取网站所有图像
     * @param url
     */
    public void getAllImgs(String url) {
        Document document = getDocumentFromUrl(url);
        Elements images = document.select("img[src~=(?i)\\.(png|jpe?g|gif)]");
        for (Element image : images) {
            System.out.println("src : " + image.attr("src"));
            System.out.println("height : " + image.attr("height"));
            System.out.println("width : " + image.attr("width"));
            System.out.println("alt : " + image.attr("alt"));
        }
        printLine();
    }

7、获取URL的元信息

元信息包括Google等搜索引擎用来确定网页内容的索引为目的。 它们以HTML页面的HEAD部分中的一些标签的形式存在。

    /**
     * 获取网站元信息
     * @param url
     */
    public void getUrlInfo(String url) {
        Document document = getDocumentFromUrl(url);

        String description = document.select("meta[name=description]").get(0).attr("content");
        System.out.println("Meta description : " + description);

        String keywords = document.select("meta[name=keywords]").first().attr("content");
        System.out.println("Meta keyword : " + keywords);
        printLine();
    }

8、在HTML页面中获取表单属性

在网页中获取表单输入元素非常简单。 使用唯一id查找form元素; 然后找到该表单中存在的所有input元素。

    /**
     * 获取表单元素
     * @param url 
     * @param formId 表单id
     */
    public void getForm(String url, String formId) {
        Document doc = getDocumentFromUrl(url);
        Element formElement = doc.getElementById(formId);

        Elements inputElements = formElement.getElementsByTag("input");
        for (Element inputElement : inputElements) {
            String key = inputElement.attr("name");
            String value = inputElement.attr("value");
            System.out.println("Param name: " + key + "\r\nParam value: " + value);
        }
    }

9、更新元素的属性/内容

可以使用Jsoup API来更新这些元素的属性或innerHTML。 例如,想更新文档中存在的“rel = nofollow”的所有链接。

Document document = getDocumentFromUrl(url);
Elements links = document.select("a[href]");  
links.attr("rel", "nofollow");

10、消除不信任的HTML(以防止XSS)

假设在应用程序中,想显示用户提交的HTML片段。 例如 用户可以在评论框中放入HTML内容。 这可能会导致非常严重的问题,如果允许直接显示此HTML。 用户可以在其中放入一些恶意脚本,并将用户重定向到另一个脏网站。

为了清理这个HTMLJsoup提供Jsoup.clean()方法。 此方法期望HTML格式的字符串,并将返回清洁的HTML。 要执行此任务,Jsoup使用白名单过滤器。 jsoup白名单过滤器通过解析输入HTML(在安全的沙盒环境中)工作,然后遍历解析树,只允许将已知安全的标签和属性(和值)通过清理后输出。

它不使用正则表达式,这对于此任务是不合适的。

清洁器不仅用于避免XSS,还限制了用户可以提供的元素的范围:您可以使用文本,强元素,但不能构造div或表元素。

    /**
     * 消除不信任的HTML(以防止XSS)
     * @param html
     */
    public void cleanXSS(String html) {
        String cleanHTML = Jsoup.clean(html, Whitelist.basic());
        System.out.println(cleanHTML);
        printLine();
    }

4、Jsoup的高级

1、Jsoup的打开方式

我们可以使用Connection对象来设置一些请求信息。比如:头信息,cookie,请求等待时间,代理等等来模拟浏览器的行为。

Document doc = Jsoup.connect("http://example.com")
  .data("query", "Java")
  .userAgent("Mozilla")
  .cookie("auth", "token")
  .timeout(3000)
  .post();

2、使用document方式获取

getElementById(String id)//通过id来获取
getElementsByTag(String tagName)//通过标签名字来获取
getElementsByClass(String className)//通过类名来获取
getElementsByAttribute(String key)//通过属性名字来获取
getElementsByAttributeValue(String key, String value)//通过指定的属性名字,属性值来获取
getAllElements()//获取所有元素

3、通过类似于css或jQuery的选择器来查找元素

  1. tagname : 通过标签查找元素,比如:a
  2. ns|tag : 通过标签在命名空间查找元素,比如:可以用 fb|name 语法来查找 <fb:name> 元素。
  3. #id : 通过id查找元素,比如:#logo
  4. .class: 通过class名称查找元素,比如:.masthead
  5. [attribute]: 利用属性查找元素,比如:[href]
  6. [^attr]: 利用属性名前缀来查找元素,比如:可以用[^data-] 来查找带有HTML5 Dataset属性的元素。
  7. [attr=value]: 利用属性值来查找元素,比如:[width=500]
  8. [attr^=value], [attr$=value], [attr=value]: 利用匹配属性值开头、结尾或包含属性值来查找元素,比如:[href=/path/]
  9. [attr~=regex]: 利用属性值匹配正则表达式来查找元素,比如:img[src~=(?i).(png|jpe?g)]
  10. *: 这个符号将匹配所有元素。
  11. el#id: 元素+id,比如:div#logo
  12. el.class: 元素+class,比如:div.masthead
  13. el[attr]: 元素+class,比如:a[href]
  14. 任意组合,比如:a[href].highlight
  15. ancestor child: 查找某个元素下子元素,比如:可以用.body p 查找在<body>元素下的所有 <p>元素。
  16. parent > child: 查找某个父元素下的直接子元素,比如:可以用div.content > p 查找 <p> 元素,也可以用body > *查找body标签下所有直接子元素。
  17. siblingA + siblingB: 查找在A元素之前第一个同级元素B,比如:div.head + div
  18. siblingA ~ siblingX: 查找A元素之前的同级X元素,比如:h1 ~ p
  19. el, el, el:多个选择器组合,查找匹配任一选择器的唯一元素,例如:div.masthead, div.logo
  20. :lt(n): 查找哪些元素的同级索引值(它的位置在DOM树中是相对于它的父节点)小于n,比如:td:lt(3) 表示小于三列的元素。
  21. :gt(n):查找哪些元素的同级索引值大于n,比如:div p:gt(2)表示哪些<div>中有包含2个以上的<p>元素。
  22. :eq(n): 查找哪些元素的同级索引值与n相等,比如:form input:eq(1)表示包含一个<input>标签的<form>元素。
  23. :has(seletor): 查找匹配选择器包含元素的元素,比如:div:has(p)表示哪些<div>包含了<p>元素。
  24. :not(selector): 查找与选择器不匹配的元素,比如:div:not(.logo) 表示不包含class="logo"元素的所有<div> 列表。
  25. :contains(text): 查找包含给定文本的元素,搜索不区分大不写,比如:p:contains(jsoup)
  26. :containsOwn(text): 查找直接包含给定文本的元素。
  27. :matches(regex): 查找哪些元素的文本匹配指定的正则表达式,比如:div:matches((?i)login)
  28. :matchesOwn(regex): 查找自身包含文本匹配指定正则表达式的元素。

上述伪选择器索引是从0开始的,也就是说第一个元素索引值为0,第二个元素index为1等

通过上面的选择器,我们可以取得一个Elements对象,它继承了ArrayList对象,里面放的全是Element对象。接下来我们要做的就是从Element对象中,取出我们真正需要的内容。

通常有下面几种方法:

  • Element.text()这个方法用来取得一个元素中的文本。
  • Element.html()Node.outerHtml()这个方法用来取得一个元素中的html内容。
  • Element.attr(String key)获得一个属性的值,例如取得超链接<a href="">href的值。

4、开源中国数据

package cays.jsoup;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

/**
 * 开源中国数据提取
 *
 * @author Chai yansheng
 * @create 2019-08-16 13:51
 **/
public class OpenChinaExample {
    public static final String USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " +
            "(KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36";

    /**
     * 获取开源中国上的软件的基本信息
     * @throws IOException
     */
    public void execute() throws IOException {
        // 填写链接到集合中
        Set<String> setUrls = new HashSet<>();
        for(int i = 1; i <= 5; i++) {
            String strUrl = "https://www.oschina.net/project/list?company=0&sort=score&lang=0&recommend=false&p="+i;
            setUrls.add(strUrl);
        }
        // 根据软件的标题访问软件详情页
        Set<String> setProjUrls = new HashSet<>();
        for(String stringUrl : setUrls) {
            Document document = Jsoup.connect(stringUrl)
                    .userAgent(USER_AGENT)
                    .get();
            //  获取软件标题的url
            Elements elements = document.select("div.item");
            for(Element element : elements) {
                Elements eleUrl = element.select("div.content a");
                String strPrjUrl = eleUrl.attr("href");
                if (strPrjUrl.isEmpty()) {
                    continue;
                }
                Elements elName = eleUrl.select(".project-name");
                String name = elName.text();
                Elements elTitle = eleUrl.select(".project-title");
                String title = elTitle.text();
                if (name.isEmpty() || title.isEmpty()) {
                    continue;
                }
                setProjUrls.add(strPrjUrl);
                System.out.println(strPrjUrl);
                System.out.println("project-name: " + name);
                System.out.println("project-title: " + title);
            }
        }
        // 遍历软件url访问软件基本信息页
        for(String stringUrl : setProjUrls) {
            Document document = Jsoup.connect(stringUrl)
                    .userAgent(USER_AGENT)
                    .get();
            // 获取软件发布标题
            Elements elements = document.select("div.info-wrap h1");
            String strTitle = elements.text();
            System.out.println("标题:" + strTitle);
            // 获取软件的基本信息
            Elements elementsSection = document.select("div.info-item");
            for (Element element : elementsSection) {
                Elements label = element.select("label");
                Elements span = element.select("span");
                System.out.println(label.text() + span.text());
            }
            System.out.println("========================================================");

        }
    }
    public static void main(String[] args) throws IOException {
        OpenChinaExample openChinaExample = new OpenChinaExample();
        openChinaExample.execute();
    }
}

5、腾讯首页图片

package cays.jsoup;

import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;

/**
 * 腾讯首页图片数据
 *
 * @author Chai yansheng
 * @create 2019-08-16 14:39
 **/
public class QQImageExample {
    public static final String USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " +
            "(KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36";

    public void downloadImage(String filePath, String imageUrl) {
        // 若指定文件夹没有,则先创建
        File dir = new File(filePath);
        if (!dir.exists()) {
            dir.mkdirs();
        }
        // 截取图片文件名
        String fileName = imageUrl.substring(imageUrl.lastIndexOf('/') + 1, imageUrl.length());

        try {
            // 文件名里面可能有中文或者空格,所以这里要进行处理。但空格又会被URLEncoder转义为加号
            String urlTail = URLEncoder.encode(fileName, "UTF-8");
            // 因此要将加号转化为UTF-8格式的%20
            imageUrl = imageUrl.substring(0, imageUrl.lastIndexOf('/') + 1) + urlTail.replaceAll("\\+", "\\%20");

        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        // 写出的路径
        File file = new File(filePath + File.separator + fileName);

        try {
            // 获取图片URL
            URL url = new URL(imageUrl);
            // 获得连接
            URLConnection connection = url.openConnection();
            // 设置10秒的相应时间
            connection.setConnectTimeout(10 * 1000);
            // 获得输入流
            InputStream in = connection.getInputStream();
            // 获得输出流
            BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
            // 构建缓冲区
            byte[] buf = new byte[1024];
            int size;
            // 写入到文件
            while (-1 != (size = in.read(buf))) {
                out.write(buf, 0, size);
            }
            out.close();
            in.close();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public void execute(String url) {
        // 利用Jsoup获得连接
        Connection connect = Jsoup.connect(url);
        try {
            connect.userAgent(USER_AGENT);
            // 得到Document对象
            Document document = connect.get();
            // 查找所有img标签
            Elements imgs = document.getElementsByTag("img");
            System.out.println("共检测到下列图片URL:");
            System.out.println("开始下载");
            // 遍历img标签并获得src的属性
            for (Element element : imgs) {
                //获取每个img标签URL "abs:"表示绝对路径
                String imgSrc = element.attr("abs:src");
                // 打印URL
                System.out.println(imgSrc);
                //下载图片到本地
                downloadImage("src\\main\\java\\cays\\img\\", imgSrc);
            }
            System.out.println("下载完成");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public static void main(String[] args) {
        QQImageExample qqImageExample = new QQImageExample();
        String url = "http://www.qq.com";
        qqImageExample.execute(url);
    }
}

6、解析json数据

引入fastjson

<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency>
  <groupId>com.alibaba</groupId>
  <artifactId>fastjson</artifactId>
  <version>1.2.59</version>
</dependency>

代码

package cays.jsoup;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.jsoup.Connection;
import org.jsoup.Jsoup;

import java.io.IOException;

/**
 * 解析Json数据
 *
 * @author Chai yansheng
 * @create 2019-08-16 14:52
 **/
public class ParseJsonExample {
    public static final String USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " +
            "(KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36";

    /**
     * 解析json数据
     * @param url
     */
    public void parseJson(String url) throws IOException {
        Connection.Response res = Jsoup.connect(url)
                .header("Accept", "*/*")
                .header("Accept-Encoding", "gzip, deflate")
                .header("Accept-Language","zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3")
                .header("Content-Type", "application/json;charset=UTF-8")
                .header("User-Agent",USER_AGENT)
                .timeout(10000).ignoreContentType(true).execute();//.get();
        String body = res.body();
        System.out.println(body);
        JSONObject json = JSON.parseObject(body);
        JSONArray jsonArray = json.getJSONArray("data");

        //JSONArray jsonArray1 = JSONArray.parseArray(JSON_ARRAY_STR);//因为JSONArray继承了JSON,所以这样也是可以的

        //遍历方式1
        int size = jsonArray.size();
        for (int i = 0; i < size; i++){
            JSONObject jsonObject = jsonArray.getJSONObject(i);
            if(jsonObject.containsKey("question")) {
                JSONObject question = jsonObject.getJSONObject("question");
                String qid = question.getString("qid");
                System.out.println(qid);
            }

        }
    }
    public static void main(String[] args) throws IOException {
        ParseJsonExample parseJsonExample = new ParseJsonExample();
        String url = "https://www.wukong.com/wenda/web/nativefeed/brow/?" +
                "concern_id=6300775428692904450&t=1533714730319&_signature=DKZ7mhAQV9JbkTPBachKdgyme4";
        parseJsonExample.parseJson(url);
    }
}
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercisong permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussong and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of usong or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arisong as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

Java的Jsoup学习,参考博客和教程,下载图片和小说 展开 收起
Java
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/chaiyansheng/JsoupDemo.git
git@gitee.com:chaiyansheng/JsoupDemo.git
chaiyansheng
JsoupDemo
JsoupDemo
master

搜索帮助