mirror of
https://github.com/VinciGit00/Scrapegraph-ai.git
synced 2026-06-28 21:01:55 +08:00
fix(ScreenShotScraper): static import of optional dependencies
This commit is contained in:
parent
16ab1bf3d9
commit
52fe441c5a
@ -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]
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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
|
||||
|
||||
@ -3,7 +3,6 @@ screenshot_preparation module
|
||||
"""
|
||||
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
|
||||
@ -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)
|
||||
@ -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]`.")
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user