1 parent 7877e07 commit cd391bdCopy full SHA for cd391bd
1 file changed
readability/readability.py
@@ -142,6 +142,16 @@ def _get_main_image_dict(self, html_string):
142
143
# Transform the html string into an lxml tree
144
doc = build_doc(html_string)
145
+
146
+ if len(list(self.tags(doc, 'img'))) == 0:
147
+ doc = build_doc(tounicode(self.html))
148
+ new_html = clean_attributes(tounicode(self._parse(self.content())))
149
+ haystack = html_string.strip()
150
+ while haystack not in new_html and len(haystack) > 20:
151
+ old_len = len(haystack)
152
+ haystack = haystack[old_len/4 : old_len/2+old_len/4]
153
+ #log.info(haystack)
154
+ doc = build_doc(new_html.split(haystack)[0])
155
156
# Build list of img tags
157
tags = []
0 commit comments