You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.7 KiB
47 lines
1.7 KiB
package com.example;
|
|
|
|
import okhttp3.*;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONObject;
|
|
import org.jsoup.Jsoup;
|
|
import org.jsoup.nodes.Document;
|
|
|
|
import java.io.IOException;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
public class jsonGetOk {
|
|
public static void main(String[] args) throws IOException {
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
.build();
|
|
MediaType mediaType = MediaType.parse("text/plain");
|
|
RequestBody body = RequestBody.create(mediaType, "");
|
|
Request request = new Request.Builder()
|
|
.url("https://www.dsscu.gov.mo/api/common/page_detail?PostType=page&EntityId=6654829e-8163-b801-0096-c02e09d690d1")
|
|
.get()
|
|
.build();
|
|
Response response = client.newCall(request).execute();
|
|
String responseBody = response.body().string();
|
|
|
|
// 解析 JSON
|
|
JSONObject jsonObject = new JSONObject(responseBody);
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
String postTime = data.getString("onlineAt");
|
|
JSONObject metas = data.getJSONObject("metas");
|
|
String title = metas.getString("name");
|
|
String summary = metas.getString("summary");
|
|
Document parse = Jsoup.parse(summary);
|
|
String content = parse.text();
|
|
String forwardcontent = responseBody;
|
|
String fileList = metas.getString("biddersFile");
|
|
fileList = fileList+"###"+"pdf";
|
|
Map<String,Object> map = new HashMap<>();
|
|
map.put("postTime",postTime);
|
|
map.put("title",title);
|
|
map.put("content",content);
|
|
map.put("forwardcontent",forwardcontent);
|
|
map.put("fileList",fileList);
|
|
System.out.println(map);
|
|
}
|
|
|
|
}
|