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
1414st .set_page_config (page_title = "Scrapegraph-ai demo" , page_icon = "🕷️" )
1515
1616# Install playwright browsers
1717playwright_install ()
1818
1919# Initialize logger
20- get_logger (level = "DEBUG " )
20+ sgai_logger . set_logging (level = "INFO " )
2121
2222def 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+
5052api_key = st .text_input ('Enter your API key:' , type = "password" , help = "API key must start with 'sgai-'" )
5153url = st .text_input ('Enter the URL to scrape:' )
5254prompt = 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
7679left_co2 , * _ , cent_co2 , last_co2 , last_c3 = st .columns ([1 ] * 18 )
0 commit comments