forked from Shubhamsaboo/awesome-llm-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocal_ai_scrapper.py
More file actions
37 lines (34 loc) · 1.15 KB
/
Copy pathlocal_ai_scrapper.py
File metadata and controls
37 lines (34 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Import the required libraries
import streamlit as st
from scrapegraphai.graphs import SmartScraperGraph
# Set up the Streamlit app
st.title("Web Scrapping AI Agent 🕵️♂️")
st.caption("This app allows you to scrape a website using Llama 3.2")
# Set up the configuration for the SmartScraperGraph
graph_config = {
"llm": {
"model": "ollama/llama3.2",
"temperature": 0,
"format": "json", # Ollama needs the format to be specified explicitly
"base_url": "http://localhost:11434", # set Ollama URL
},
"embeddings": {
"model": "ollama/nomic-embed-text",
"base_url": "http://localhost:11434", # set Ollama URL
},
"verbose": True,
}
# Get the URL of the website to scrape
url = st.text_input("Enter the URL of the website you want to scrape")
# Get the user prompt
user_prompt = st.text_input("What you want the AI agent to scrape from the website?")
# Create a SmartScraperGraph object
smart_scraper_graph = SmartScraperGraph(
prompt=user_prompt,
source=url,
config=graph_config
)
# Scrape the website
if st.button("Scrape"):
result = smart_scraper_graph.run()
st.write(result)