Skip to content

Commit a67fde7

Browse files
committed
fix: erorr bug
1 parent 310a660 commit a67fde7

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

main.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,31 @@ def save_email(email):
4646
with cent_co:
4747
st.image("assets/scrapegraphai_logo.png")
4848

49-
# Use only text input for API key
50-
api_key = st.text_input('Enter your API key:')
49+
# Use password input for API key to mask it
50+
api_key = st.text_input('Enter your API key:', type="password", help="API key must start with 'sgai-'")
5151
url = st.text_input('Enter the URL to scrape:')
5252
prompt = st.text_input('Enter your prompt:')
5353

54-
# Initialize client with the input API key
55-
client = SyncClient(api_key=api_key)
56-
5754
# When the user clicks the 'Scrape' button
5855
if st.button('Scrape'):
59-
try:
60-
response = client.smartscraper(
61-
website_url=url,
62-
user_prompt=prompt
63-
)
64-
st.write(response['result'])
65-
except Exception as e:
66-
st.write(f"Error: {str(e)}")
67-
finally:
68-
client.close()
56+
if not api_key.startswith('sgai-'):
57+
st.error("Invalid API key format. API key must start with 'sgai-'")
58+
elif not url:
59+
st.error("Please enter a URL to scrape")
60+
elif not prompt:
61+
st.error("Please enter a prompt")
62+
else:
63+
try:
64+
client = SyncClient(api_key=api_key)
65+
response = client.smartscraper(
66+
website_url=url,
67+
user_prompt=prompt
68+
)
69+
st.write(response['result'])
70+
except Exception as e:
71+
st.error(f"Error: {str(e)}")
72+
finally:
73+
client.close()
6974

7075

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

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ pandas>=2.2.2
22
scrapegraphai==1.12.0
33
scrapegraphai
44
streamlit>=1.0
5-
scrapegraph-py==0.0.2
5+
scrapegraph-py==1.4.1

0 commit comments

Comments
 (0)