Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ more-browser-options = [
screenshot_scraper = [
"surya-ocr>=0.5.0; python_version >= '3.10'",
"matplotlib>=3.7.2; python_version >= '3.10'",
"ipywidgets>=8.1.0; python_version >= '3.10'"
"ipywidgets>=8.1.0; python_version >= '3.10'",
"pillow>=10.4.0",
]

[build-system]
Expand Down
9 changes: 9 additions & 0 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ idna==3.7
# via yarl
imagesize==1.4.1
# via sphinx
importlib-metadata==8.4.0
# via sphinx
importlib-resources==6.4.4
# via matplotlib
iniconfig==2.0.0
# via pytest
isort==5.13.2
Expand Down Expand Up @@ -450,8 +454,10 @@ typing-extensions==4.12.2
# via pydantic
# via pydantic-core
# via pyee
# via pylint
# via sf-hamilton
# via sqlalchemy
# via starlette
# via streamlit
# via typing-inspect
# via uvicorn
Expand All @@ -471,3 +477,6 @@ uvicorn==0.30.5
# via burr
yarl==1.9.4
# via aiohttp
zipp==3.20.1
# via importlib-metadata
# via importlib-resources
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
import asyncio
from io import BytesIO
from PIL import Image, ImageGrab
from playwright.async_api import async_playwright
import numpy as np
from io import BytesIO
Expand All @@ -18,6 +17,10 @@ async def take_screenshot(url: str, save_path: str = None, quality: int = 100):
Returns:
PIL.Image: The screenshot of the webpage as a PIL Image object.
"""
try:
from PIL import Image
except:
raise ImportError("The dependencies for screenshot scraping are not installed. Please install them using `pip install scrapegraphai[screenshot_scraper]`.")

async with async_playwright() as p:
browser = await p.chromium.launch(headless=True)
Expand All @@ -43,6 +46,7 @@ def select_area_with_opencv(image):

try:
import cv2 as cv
from PIL import ImageGrab
except ImportError:
raise ImportError("The dependencies for screenshot scraping are not installed. Please install them using `pip install scrapegraphai[screenshot_scraper]`.")

Expand Down