Skip to content

Commit

Permalink
fix: demo
Browse files Browse the repository at this point in the history
  • Loading branch information
VinciGit00 committed Dec 10, 2024
1 parent e7220af commit 8472d92
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
17 changes: 10 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
playwright_install,
add_download_options
)
from scrapegraph_py import SyncClient
from scrapegraph_py.logger import get_logger
from scrapegraph_py import Client
from scrapegraph_py.logger import sgai_logger

st.set_page_config(page_title="Scrapegraph-ai demo", page_icon="🕷️")

# Install playwright browsers
playwright_install()

# Initialize logger
get_logger(level="DEBUG")
sgai_logger.set_logging(level="INFO")

def save_email(email):
with open("mails.txt", "a") as file:
Expand Down Expand Up @@ -47,6 +47,8 @@ def save_email(email):
st.image("assets/scrapegraphai_logo.png")

# Use password input for API key to mask it
st.write("### You can buy the API credits [here](https://scrapegraphai.com)")

api_key = st.text_input('Enter your API key:', type="password", help="API key must start with 'sgai-'")
url = st.text_input('Enter the URL to scrape:')
prompt = st.text_input('Enter your prompt:')
Expand All @@ -61,16 +63,17 @@ def save_email(email):
st.error("Please enter a prompt")
else:
try:
client = SyncClient(api_key=api_key)
response = client.smartscraper(
sgai_client = Client(api_key=api_key)
response = sgai_client.smartscraper(
website_url=url,
user_prompt=prompt
)
st.write(response['result'])
st.write(f"Request ID: {response['request_id']}")
st.write(f"Result: {response['result']}")
except Exception as e:
st.error(f"Error: {str(e)}")
finally:
client.close()
sgai_client.close()


left_co2, *_, cent_co2, last_co2, last_c3 = st.columns([1] * 18)
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ boto3==1.35.36
langchain_core==0.3.21
pandas==2.2.3
Requests==2.32.3
scrapegraph_py==1.4.3
scrapegraph-py==1.9.0b2
scrapegraphai==1.32.0
streamlit==1.39.0
streamlit==1.39.0

0 comments on commit 8472d92

Please sign in to comment.