def extract_image_url(text):
text = _strip_url(text)
imgurl = None
if text:
# check if the text is style content
match = _CSS_IMAGERE.search(text)
text = match.groups()[0] if match else text
parsed = urlparse(text)
path = None
match = _IMAGE_PATH_RE.search(parsed.path)
if match:
path = match.group()
elif parsed.query:
match = _GENERIC_PATH_RE.search(parsed.path)
if match:
path = match.group()
if path is not None:
parsed = list(parsed)
parsed[2] = path
imgurl = urlunparse(parsed)
if not imgurl:
imgurl = text
return imgurl
评论列表
文章目录