我正在使用Retrofit从Url获取html页面源代码。但是Retrofit只是html页面源代码的一部分
我试图将ResponseBody更改为String,但是没有用。
private static final String TAG = "TESTTESTTESTTEST";
private static String url = "https://www.hepsiburada.com/lassa-235-65r17-108h-xl-competush-l-p-OTLST216410?magaza=LastikArt%C4%B1&utm_source=pc&utm_medium=cimri&utm_campaign=c&utm_content=c&utm_term=5083&wt_pc=cimri.c.5083.pc/";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://www.google.com/")
.client(getOkHttpClient())
.addConverterFactory(ScalarsConverterFactory.create())
.build();
IGetHtml iGetHtml = retrofit.create(IGetHtml.class);
Call<ResponseBody> stringCall = iGetHtml.getHtml(url);
stringCall.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
if (response.isSuccessful()) {
try {
Log.e(TAG, "onResponse: " + response.body().string());
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
Log.e(TAG, "onFailure: " + t);
}
});
}
private OkHttpClient getOkHttpClient() {
OkHttpClient client = new OkHttpClient();
try {
client = new OkHttpClient.Builder()
.sslSocketFactory(new TLSSocketFactory())
.build();
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return client;
}
我希望完整的页面源,但是它只返回页面源的一小部分(返回约4271个字符)。