Hab selbst hinbekommen... Die Raspberry Pi Welt hat jetzt wieder Screenshots für ihre Flatpaks xD
Python
import requests
from bs4 import BeautifulSoup
def find_og_image(url):
try:
# Send an HTTP GET request to the URL
response = requests.get(url)
response.raise_for_status() # Check if the request was successful
# Parse the HTML content using BeautifulSoup
soup = BeautifulSoup(response.text, 'html.parser')
# Find the meta tag with property="og:image"
og_image_tag = soup.find("meta", property="og:image")
# Extract the content of the og:image tag if it exists
if og_image_tag:
og_image_content = og_image_tag.get("content")
return og_image_content
else:
print("No og:image meta property found.")
return None
except requests.exceptions.RequestException as e:
print("Error fetching URL:", e)
return None
if __name__ == "__main__":
url = "https://flathub.org/apps/org.americanmonk.TipitakaPaliReader"
og_image_url = find_og_image(url)
if og_image_url:
print(f"The 'og:image' URL is: {og_image_url}")
else:
print("Failed to find the 'og:image' meta property.")
Alles anzeigen