diff --git a/main.py b/main.py index 2991433..91191d0 100644 --- a/main.py +++ b/main.py @@ -8,8 +8,8 @@ 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="🕷️") @@ -17,7 +17,7 @@ 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: @@ -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:') @@ -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) diff --git a/requirements.txt b/requirements.txt index 16321c2..0f6503e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 \ No newline at end of file +streamlit==1.39.0