android - 如何仅从 android 中的网页 url 获取图像
问题描述
我正在使用 google Fact Check API 制作一个应用程序,响应 json 是这样的
{
"claims": [
{
"text": "“President El-Sisi confirmed Egypt's unwavering strategic position on Libya, which aimed at restoring stability in the country, preserving its national institutions, and preventing further deterioration in Libya’s security situation via curbing illegal foreign interference in the Libyan issue.”",
"claimant": "Abdel-Fattah al-Sisi",
"claimDate": "2020-07-24T00:00:00Z",
"claimReview": [
{
"publisher": {
"name": "POLYGRAPH.info",
"site": "polygraph.info"
},
"url": "https://www.polygraph.info/a/egypt-libya-sisi-intervention/30745850.html",
"title": "Egypt's al-Sisi Told Trump Foreign Interference in Libya is Bad – Just as his Parliament Authorized him to Intervene",
"reviewDate": "2020-07-24T00:00:00Z",
"textualRating": "Misleading",
"languageCode": "en"
}
]
}
],
"nextPageToken": "CAE"
}
我想知道如何获取 urls 图像并像这个 图像一样显示它
我似乎无法弄清楚如何获取图像,因为在 JSON 中只有网页的 url。
编辑:- 这是我使用 GSON 存储值的代码
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest
(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.i("response",response.toString());
Search search = gson.fromJson(response.toString(),Search.class);
Log.i("response",search.toString());
textView.setText("Claim:- "+search.claims.get(0).text+"\nFactual Rating:-"+search.claims.get(0).claimReview.get(0).textualRating);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.i("response",error.toString());// TODO: Handle error
}
});
解决方案
如果您知道确切的网站,则可以使用网络抓取工具。看看你怎么能在这里做到。
推荐阅读
- vue.js - 如何在自定义 VuePress 组件中使用 vue-i18n?
- javascript - 如何在子集合中制作虚拟对象 - Mogoose
- linux - 如何使用 cdo 命令在 c shell 上打开 25 个具有相同结构的文件并将内容复制到一个文件中
- python - python中的分裂chromedriver崩溃
- gitlab - GitLab web ui 导航更改
- php - 我的 select all 功能在本地完美运行,但是当我托管它时给了我一个致命错误
- bash - Bash 脚本 If 语句比较用户输入,找不到命令
- json - 如何修复 Python Elasticsearch 批量的 RequestError?
- apache-nifi - 如何在 RouteOnAtrribute 上应用条件以过滤 NIFI 中的 json 数据
- javascript - 在动态 html 元素上添加点击事件