感觉是时候 把我的老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("---------------------------------");
});
}
}
这样便签的内容就抓取出来了