@@ -46,26 +46,31 @@ def save_email(email):
4646with 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-'" )
5151url = st .text_input ('Enter the URL to scrape:' )
5252prompt = 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
5855if 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
7176left_co2 , * _ , cent_co2 , last_co2 , last_c3 = st .columns ([1 ] * 18 )
0 commit comments