HawkeyeHS commited on
Commit
9636ab8
·
1 Parent(s): 095d14f

Add extract image endpoint

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -9,6 +9,7 @@ from PIL import Image
9
  import requests
10
  from io import BytesIO
11
  from bs4 import BeautifulSoup
 
12
 
13
  os.environ["CUDA_VISIBLE_DEVICES"] = ""
14
 
@@ -33,7 +34,7 @@ def extract_images():
33
 
34
  img_tags = soup.select('div img')
35
  for img_tag in img_tags:
36
- img_url = img_tag['src']
37
  img_urls.append(img_url)
38
  return json.dumps({"images":img_urls})
39
  except Exception as e:
 
9
  import requests
10
  from io import BytesIO
11
  from bs4 import BeautifulSoup
12
+ from urllib.parse import urljoin
13
 
14
  os.environ["CUDA_VISIBLE_DEVICES"] = ""
15
 
 
34
 
35
  img_tags = soup.select('div img')
36
  for img_tag in img_tags:
37
+ img_url = urljoin(src, img_tag['src'])
38
  img_urls.append(img_url)
39
  return json.dumps({"images":img_urls})
40
  except Exception as e: