def get_gramet_image_url(url_or_fp):
img_src = ''
if isinstance(url_or_fp, io.IOBase):
# noinspection PyUnresolvedReferences
data = url_or_fp.read()
u = urlsplit(OGIMET_URL)
else:
u = urlsplit(url_or_fp)
import requests
r = requests.get(url_or_fp)
data = r.text
if data:
m = re.search(r'<img src="([^"]+/gramet_[^"]+)"', data)
if m:
img_src = "{url.scheme}://{url.netloc}{path}".format(
url=u, path=m.group(1))
return img_src
评论列表
文章目录