HTML 解析框架 Fruit-HTML

码农软件 · 软件分类 · HTML解析器 · 2019-04-02 16:11:53

软件介绍

Fruit

简单的说Fruit之于html正如Gson之于Json,它能让你以一种注解的方式来描述解析的逻辑。下面是一个例子:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public class FruitInfo {
    @Pick("div#only")
    private String favorite;
    @Pick(value = "div#only", attr = Attrs.OWN_TEXT)
    private String favoriteOne;
    @Pick(value = "div#only", attr = Attrs.HTML)
    private String favoriteHtml;
    @Pick(value = "img.apple", attr = Attrs.SRC)
    private String img;
    @Pick(value = "a.author", attr = Attrs.HREF)
    private String blog;
    @Pick("div.fruit")
    private List<Item> items;

    public static class Item {
        @Pick("strong.name")
        private String name;
        @Pick(".color")
        private String color;
        @Pick(attr = "id")
        private int id;
    }
}

这里就不做更多的说明了,GitHub项目主页有更丰富的使用说明,欢迎访问查看。

V2er

V2er就是开始时说的那个要开发的V2EX客户端。
这个APP的开发是从去年底开始一直到今年9月中旬基本开发完成,到现在也迭代了几个版本,在市场上也获得了很多用户的好评与鼓励平均评分在4.8
欢迎各位朋友去下载使用,在Google Play酷安市场已上架。

前几天也写了个基本版 - V2er-Core把V2er的核心代码开源了。这个小项目完整的展示了如何利用 “Fruit/Retrofit2/OKHttp3/RxJava” 来开发这种APP(数据大部分来源于html及少量json接口)
下面一段代码是最终实现后的Retrofit API Service代码样例(是不是看上去和使用真的Json接口一样)

1
2
3
4
5
6
7
public interface APIs {
    @GET("/api/topics/hot.json") @Json
    Observable<DailyHotInfo> dailyHot();

    @GET("/") @Html
    Observable<NewsInfo> homeNews(@Query("tab") String tab);
}

最后再贴一张V2er-Core实现的效果图:


大家可以去这里找到它的源码。

本文地址:https://www.codercto.com/soft/d/2708.html

Operating System Algorithms

Operating System Algorithms

Nathan Adams、Elisha Chirchir / CreateSpace Independent Publishing Platform / 2017-4-21 / USD 39.15

Operating System Algorithms will walk you through in depth examples of algorithms that you would find in an operating system. Selected algorithms include process and disk scheduling.一起来看看 《Operating System Algorithms》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

MD5 加密
MD5 加密

MD5 加密工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具