AI Scraper Selenium App

Start with this template
174
import json
from abilities import llm_prompt
from fastapi import Request
import logging

import uvicorn
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates
from fastapi.staticfiles import StaticFiles
from selenium_utils import SeleniumUtility

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

app = FastAPI()
templates = Jinja2Templates(directory="templates")
app.mount("/static", StaticFiles(directory="static"), name="static")

@app.get("/", response_class=HTMLResponse)
async def form_page(request: Request):
    return templates.TemplateResponse("form.html", {"request": request})

@app.post("/process-page-info", response_class=HTMLResponse)
Get full code

AI Scraper Selenium App

Created: | Last Updated:

Introduction to the AI Scraper Selenium App Template

Welcome to the AI Scraper Selenium App template! This template is designed to help you build a web scraping application that leverages the power of AI to extract and process information from web pages. With this template, you can submit a URL and a question, and the app will retrieve the relevant text from the page and use an AI model to generate a summary or answer your question.

The template includes a Selenium utility for web scraping, a FastAPI backend to handle web requests, and HTML templates for the user interface. It's perfect for non-technical builders who want to create powerful web scraping tools without diving into the complexities of code.

Getting Started

To begin using this template, simply click on "Start with this Template" on the Lazy platform. This will set up the code in the Lazy Builder interface, so you won't need to copy, paste, or delete any code manually.

Test: Deploying the App

Once you've started with the template, press the "Test" button to deploy the app. The Lazy platform will handle the deployment process, and you won't need to worry about installing libraries or setting up your environment. After pressing "Test," the Lazy CLI will prompt you for any required user input.

Entering Input

If the template code requires user input, you will be prompted to provide it through the Lazy CLI after pressing the "Test" button. For this template, you will need to enter the URL of the web page you want to scrape and the question you want to ask about the content on that page.

Using the App

After deployment, Lazy will print a dedicated server link that you can use to interact with the app. If you're using FastAPI, you will also be provided with a link to the API documentation. Navigate to the provided server link to access the web interface where you can submit URLs and questions.

The web interface is straightforward: enter the URL of the page you want to scrape in the provided field, type your question, and hit submit. The app will then display the information retrieved from the page along with the AI's response to your question.

Integrating the App

If you wish to integrate this app into another service or frontend, you may need to use the server link provided by Lazy. For example, you could use the API endpoints to send requests from another application or add the web components to an external tool.

If your integration requires specific permissions or code placement, ensure you follow the guidelines provided by the external tool you're integrating with.

Remember, this template is designed to work seamlessly on the Lazy platform, so all the heavy lifting of code execution and environment management is taken care of for you. Enjoy building your AI-powered web scraper with ease!

Technologies

Selenium Selenium