def fetch_metadata(url): """ Return a dictionary of OpenGraph metadata found in HTML of given url """ url = url base_url = "https://opengraph.lewagon.com/" params = dict() params["url"] = url r = requests.get(base_url, params=params) response = r.json() if r'site_name' in response.keys(): description = response['data']['site_name'] title = response['data']['title'] return [title, description] else: return [None,,None]
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter