Skip to content

Commit 8472d92

Browse files
committed
fix: demo
1 parent e7220af commit 8472d92

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

main.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
playwright_install,
99
add_download_options
1010
)
11-
from scrapegraph_py import SyncClient
12-
from scrapegraph_py.logger import get_logger
11+
from scrapegraph_py import Client
12+
from scrapegraph_py.logger import sgai_logger
1313

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

1616
# Install playwright browsers
1717
playwright_install()
1818

1919
# Initialize logger
20-
get_logger(level="DEBUG")
20+
sgai_logger.set_logging(level="INFO")
2121

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

4949
# Use password input for API key to mask it
50+
st.write("### You can buy the API credits [here](https://scrapegraphai.com)")
51+
5052
api_key = st.text_input('Enter your API key:', type="password", help="API key must start with 'sgai-'")
5153
url = st.text_input('Enter the URL to scrape:')
5254
prompt = st.text_input('Enter your prompt:')
@@ -61,16 +63,17 @@ def save_email(email):
6163
st.error("Please enter a prompt")
6264
else:
6365
try:
64-
client = SyncClient(api_key=api_key)
65-
response = client.smartscraper(
66+
sgai_client = Client(api_key=api_key)
67+
response = sgai_client.smartscraper(
6668
website_url=url,
6769
user_prompt=prompt
6870
)
69-
st.write(response['result'])
71+
st.write(f"Request ID: {response['request_id']}")
72+
st.write(f"Result: {response['result']}")
7073
except Exception as e:
7174
st.error(f"Error: {str(e)}")
7275
finally:
73-
client.close()
76+
sgai_client.close()
7477

7578

7679
left_co2, *_, cent_co2, last_co2, last_c3 = st.columns([1] * 18)

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ boto3==1.35.36
22
langchain_core==0.3.21
33
pandas==2.2.3
44
Requests==2.32.3
5-
scrapegraph_py==1.4.3
5+
scrapegraph-py==1.9.0b2
66
scrapegraphai==1.32.0
7-
streamlit==1.39.0
7+
streamlit==1.39.0

0 commit comments

Comments
 (0)