|
import streamlit as st |
|
from firecrawl import FirecrawlApp |
|
|
|
|
|
st.title("Web Scraper using Firecrawl API") |
|
st.markdown("Enter a URL to scrape its content:") |
|
|
|
|
|
api_key = st.text_input("Enter Firecrawl API Key:", type="password") |
|
url = st.text_input("Enter URL:") |
|
format_option = st.selectbox("Select Output Format:", ["plain_text", "markdown", "json"]) |
|
|
|
|
|
def scrape_website(api_key, url, format_option): |
|
try: |
|
app = FirecrawlApp(api_key=api_key) |
|
response = app.scrape_url(url=url, params={'formats': [format_option]}) |
|
return response.get('content', str(response)) |
|
except Exception as e: |
|
return str(e) |
|
|
|
|
|
|
|
if st.button("Scrape Website"): |
|
if api_key and url: |
|
with st.spinner("Scraping..."): |
|
result = scrape_website(api_key, url, format_option) |
|
st.subheader("Scraped Content:") |
|
st.text_area("Response:", str(result), height=300) |
|
else: |
|
st.error("Please enter both API key and URL!") |
|
|