"""
example of scraping with screenshots
"""
import asyncio
from scrapegraphai.utils.screenshot_scraping import (take_screenshot,
select_area_with_opencv,
crop_image, detect_text)
image = asyncio.run(take_screenshot(
url="https://colab.google/",
save_path="Savedscreenshots/test_image.jpeg",
quality = 50
))
LEFT, TOP, RIGHT, BOTTOM = select_area_with_opencv(image)
print("LEFT: ", LEFT, " TOP: ", TOP, " RIGHT: ", RIGHT, " BOTTOM: ", BOTTOM)
cropped_image = crop_image(image, LEFT=LEFT, RIGHT=RIGHT,TOP=TOP,BOTTOM=BOTTOM)
TEXT = detect_text(
cropped_image,
languages = ["en"]
)
print("DETECTED TEXT: ")
print(TEXT)