Я хочу найти изображение, которое лучше всего представляет веб-страницу.
Мой код:
from bs4 import BeautifulSoup #Import stuff
import requests
r = requests.get("http://www.test.com/") #Download website source
data = r.text #Get the website source as text
soup = BeautifulSoup(data) #Setup a "soup" which BeautifulSoup can search
links = []
for link in soup.find_all('img'): #Cycle through all 'img' tags
imgSrc = link.get('src') #Extract the 'src' from those tags
links.append(imgSrc) #Append the source to 'links'
print(links) #Print 'links'
Я знаю, что этот три метода могут быть полезны:
Check for Open Graph/Twitter Card tags
Find the largest suitable image on the page
Look for a suitable video thumbnail if no image is found
Я хочу получать самые большие изображения на страницах в зависимости от их размеров.
Я провел исследование по этому вопросу, но не смог найти что-то хорошее и быстрое для выполнения.