首页 > 解决方案 > 如何将图标预览添加到谷歌商店应用程序的 html 列表中?

问题描述

基本上我有一个 html 文件中的谷歌应用程序链接列表,我希望这些链接显示链接的应用程序的预览(无需搜索,然后手动添加每个应用程序的图像/图标 url)。可能吗?

 

<html><body>
 <ul>
      <li> <a href="https://play.google.com/store/apps/details?id=com.adobe.reader">Adobe Acrobat</a> 
      </li>
      <li> <a href="https://play.google.com/store/apps/details?id=org.mozilla.firefox">Firefox</a> 
      </li>
 </ul>
</body></html>

标签: html

解决方案


使用 python,您可以在页面的元标记中抓取社交媒体图像预览。

import urllib.request
from bs4 import BeautifulSoup

page = urllib.request.urlopen('https://play.google.com/store/apps/details?id=com.adobe.reader')

html = BeautifulSoup(page.read(), "html.parser")
for tags in html.find_all('meta'):
    if tags.get("property") == "og:image":
        print(tags.get("content"))

这将返回一个指向图像的链接,您可以将其导入到您的 html 文件中,也可以手动复制它。


推荐阅读