魅族 便签导出

感觉是时候 把我的老pro5 的便签导出了,但是苦苦寻找就是没有找到具体方法。

最终大体思路:

1.登录网页版,查看便签的请求接口

2.用postman模拟请求,抓取全部json数据

3.代码解析json,提取便签内容


下面是具体步骤:

1.查看网页的便签获取接口

2.用postman 模拟接口抓取全部数据

3.接下来就是写个代码 解析这个json 文件了

代码解析一下

public class Test3 {

    public static StringBuilder reader(String filePath) {
        try {
            StringBuilder stringBuilder = new StringBuilder();
            File file = new File(filePath);
            if (file.isFile() && file.exists()) {
                InputStreamReader read = new InputStreamReader(new FileInputStream(file), "UTF-8");
                BufferedReader bufferedReader = new BufferedReader(read);
                stringBuilder.append(bufferedReader.readLine());
            }
            return stringBuilder;
        } catch (UnsupportedEncodingException | FileNotFoundException e) {
            System.out.println("Cannot find the file specified!");
            e.printStackTrace();
        } catch (IOException e) {
            System.out.println("Error reading file content!");
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {

        StringBuilder result =
            reader("a.json");
        JSONObject responseJson = JSONObject.parseObject(result.toString());
        String returnValue = responseJson.getString("returnValue");
        JSONObject returnValueJson = JSONObject.parseObject(returnValue);
        JSONArray content = returnValueJson.getJSONArray("content");

        Map<String,String> map = new HashMap<>();
        for (int i = 0; i < content.size(); i++) {
            String createTime = content.getJSONObject(i).getString("createTime");
            String title = content.getJSONObject(i).getString("title");
            map.put(createTime,title);
        }

        map.forEach((key,value) -> {
            System.out.println(LocalDateTimeUtils.millisecond2String(Long.valueOf(key)));
            System.out.println(value);
            System.out.println("---------------------------------");
        });
    }
}

这样便签的内容就抓取出来了

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值