android - 改造不返回完整的响应体
问题描述
我正在使用 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 个字符)。
解决方案
推荐阅读
- polymer - 如何处理点击事件并在 Lit-Element 中附加 HTML?
- gremlin - 如何在不使用图形计算机(OLAP 事务)的情况下以 gremlin 查询语言实现 PageRank 算法?
- javascript - FlatList React Native 上没有重载匹配
- email - Google 表格 - 带有动态消息标签的电子邮件
- server - 8035 端口在 0.0.0.0:8035 上运行,但无法使用 Digital Ocean 的服务器 IP 地址访问它
- spring - 在 Spring Data JDBC 中初始化存储库 bean 时出错。自动配置不适用于 Spring 数据 Jdbc
- javascript - Chart.js 2.9.4 - 如何为轴 min\max 和时间轴标签分隔设置边距
- python - 如何使用 python 将 .dst 文件转换为 .jpg 格式?
- yahoo-finance - 分析数据到电子表格
- amazon-web-services - aws lambda 在不同的 ec2 机器上创建不同的初始化脚本