实际上,我有两个问题,我有一个这样的json
[
{
"id": 601,
"imdb_id": "tt0068646",
"imdb_rating": "9.2",
"language": "English, Italian, Latin",
"poster": "https://m.media-amazon.com/images/M/MV5BM2MyNjYxNmUtYTAwNi00MTYxLWJmNWYtYzZlODY3ZTk3OTFlXkEyXkFqcGdeQXVyNzkwMjQ5NzM@._V1_SX300.jpg",
"title": "The Godfather",
"year": 1972
},
{
"id": 603,
"imdb_id": "tt0071562",
"imdb_rating": "9.0",
"language": "English, Italian, Spanish, Latin, Sicilian",
"poster": "https://m.media-amazon.com/images/M/MV5BMWMwMGQzZTItY2JlNC00OWZiLWIyMDctNDk2ZDQ2YjRjMWQ0XkEyXkFqcGdeQXVyNzkwMjQ5NzM@._V1_SX300.jpg",
"title": "The Godfather Part II",
"year": 1974
},
{
"id": 622,
"imdb_id": "tt0108052",
"imdb_rating": "9.0",
"language": "English, Hebrew, German, Polish, Latin",
"poster": "https://m.media-amazon.com/images/M/MV5BNDE4OTMxMTctNmRhYy00NWE2LTg3YzItYTk3M2UwOTU5Njg4XkEyXkFqcGdeQXVyNjU0OTQ0OTY@._V1_SX300.jpg",
"title": "Schindler's List",
"year": 1993
}
]
执行json2html并像这样返回后
movies_data = get_recommended_movies().json
for movie_data in movies_data:
imdb_id = movie_data["imdb_id"]
movie_data["imdb_id"] = "https://www.imdb.com/title/" + imdb_id
#movies_data = json.dumps(get_recommended_movies().json)
html_data = json2html.convert(json=movies_data)
return html_data
这个网页是用表格呈现的,我的问题是如何将海报的网址呈现为表格中的图片,以及如何将它显示为表格中的可点击网址
1条答案
按热度按时间x8diyxa71#
这是不可能的库,不能支持html模板,只能转换json到一个html表
您可以尝试添加一些javascript,但我的建议是使用其他库,最新版本太旧(Jul 3,2019)
检查https://handlebarsjs.com/