Skip to content

Commit a1c3fa5

Browse files
committed
small refactor of image extraction
1 parent 1fb55bd commit a1c3fa5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

scrapy/contrib/ibl/extractors.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ def image_url(http://github.com/txt):
132132
['http://s7d5.scene7.com/is/image/wasserstrom/165133?wid=227&hei=227&defaultImage=noimage_wasserstrom']
133133
134134
"""
135+
imgurl = extract_image_url(txt)
136+
return [safe_url_string(remove_entities(url(imgurl)))] if imgurl else None
137+
138+
def extract_image_url(txt):
135139
txt = url(txt)
136140
imgurl = None
137141
if txt:
@@ -153,4 +157,4 @@ def image_url(http://github.com/txt):
153157
imgurl = urlparse.urlunparse(parsed)
154158
if not imgurl:
155159
imgurl = txt
156-
return [safe_url_string(remove_entities(url(imgurl)))] if imgurl else None
160+
return imgurl

0 commit comments

Comments
 (0)