From 2507b4148b6e7575369c5f3bcb03771736e81c6d Mon Sep 17 00:00:00 2001 From: James Quacinella Date: Thu, 2 Jul 2015 16:11:17 -0400 Subject: [PATCH] Find all og property values across whole document, not just the header (as some sites improperly put og tags in the body) --- opengraph/opengraph.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/opengraph/opengraph.py b/opengraph/opengraph.py index 9cedb97..5512326 100644 --- a/opengraph/opengraph.py +++ b/opengraph/opengraph.py @@ -58,7 +58,11 @@ def parser(self, html): doc = BeautifulSoup(html) else: doc = html - ogs = doc.html.head.findAll(property=re.compile(r'^og')) + + # Some sites only have og tags in the header, some in the body + # ogs = doc.html.head.findAll(property=re.compile(r'^og')) + ogs = doc.html.findAll(property=re.compile(r'^og')) + for og in ogs: if og.has_attr(u'content'): self[og[u'property'][3:]]=og[u'content']