Files
zulip/zerver/lib/url_preview/parsers/open_graph.py
rht 3f4bf2d22f zerver/lib: Use python 3 syntax for typing.
Extracted from a larger commit by tabbott because these changes will
not create significant merge conflicts.
2017-11-21 20:56:40 -08:00

14 lines
411 B
Python

import re
from typing import Dict, Text
from .base import BaseParser
class OpenGraphParser(BaseParser):
def extract_data(self) -> Dict[str, Text]:
meta = self._soup.findAll('meta')
content = {}
for tag in meta:
if tag.has_attr('property') and 'og:' in tag['property']:
content[re.sub('og:', '', tag['property'])] = tag['content']
return content