从域名中抓取公司徽标



我正在使用python从域名中抓取公司徽标。

import requests
url = "https://logo.clearbit.com/shopify.com"
payload={}
headers = {}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)

然而,它只是渲染图像,但我需要徽标的源url。

请帮忙!

感谢

您可以尝试使用requests_html库。。。。

pip install requests-html

from requests_html import HTMLSession
session = HTMLSession()
response = session.get('https://en.wikipedia.org/wiki/Pepsi')
selector = response.html.xpath("//img[contains(@alt,'logo')]/@src")[0]
print(selector)

输出:

//upload.wikimedia.org/wikipedia/commons/thumb/0/0f/Pepsi_logo_2014.svg/140px-Pepsi_logo_2014.svg.png

最新更新