通过FastJson和okhttp3库爬取数据

private String getPageContentSync(String url){
    OkHttpClient okHttpClient =new OkHttpClient();
    Request request = new Request.Builder().url(url).build();
    Call call = okHttpClient.newCall(request);
    String result = null;
    try {
      result = call.execute().body().string();
    } catch (IOException e) {
      e.printStackTrace();
    }
    return result;
  }
posted on 2022-04-22 16:52  柿子Persimmon  阅读(71)  评论(0)    收藏  举报