From 3de252c96bb4688e2f06be909f58b6c07daea2b4 Mon Sep 17 00:00:00 2001 From: Myned Date: Mon, 16 Oct 2017 02:06:33 -0400 Subject: [PATCH] get_image() from post --- src/main/utils/scraper.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/utils/scraper.py b/src/main/utils/scraper.py index 73b03e6..1c4fabc 100644 --- a/src/main/utils/scraper.py +++ b/src/main/utils/scraper.py @@ -7,7 +7,7 @@ from misc import exceptions as exc from utils import utils as u -async def check_match(url): +async def get_post(url): content = await u.fetch('http://iqdb.harry.lu', params={'url': url}) try: @@ -22,3 +22,12 @@ async def check_match(url): except AttributeError: raise exc.MissingArgument + + +async def get_image(url): + content = await u.fetch(url) + + value = html.fromstring(content).xpath( + 'string(/html/body/div[@id="content"]/div[@id="post-view"]/div[@class="content"]/div[2]/img/@src)') + + return value