@@ -152,19 +152,28 @@ print(f"Found {len(parsed['links'])} links")
152152
153153#### ` extract() `
154154``` python
155- # Simple AI-powered extraction using natural language
156- result = client.extract(" extract the latest news headlines from bbc.com" )
157- print (result) # Prints extracted headlines directly
158-
159- # Extract specific information with custom query
160- result = client.extract(" get product name and price from amazon.com/dp/B079QHML21" )
161- print (f " Product info: { result} " )
162- print (f " Source: { result.url} " )
163- print (f " Tokens used: { result.token_usage[' total_tokens' ]} " )
164-
165- # Extract structured data
166- result = client.extract(" find contact information and business hours from company-website.com" )
167- print (result) # AI-formatted contact details
155+ # Basic extraction (URL in query)
156+ result = client.extract(" Extract news headlines from CNN.com" )
157+ print (result)
158+
159+ # Using URL parameter with structured output
160+ schema = {
161+ " type" : " object" ,
162+ " properties" : {
163+ " headlines" : {
164+ " type" : " array" ,
165+ " items" : {" type" : " string" }
166+ }
167+ },
168+ " required" : [" headlines" ]
169+ }
170+
171+ result = client.extract(
172+ query = " Extract main headlines" ,
173+ url = " https://cnn.com" ,
174+ output_scheme = schema
175+ )
176+ print (result) # Returns structured JSON matching the schema
168177```
169178
170179#### ` connect_browser() `
@@ -265,13 +274,15 @@ Extract and parse useful information from API responses.
265274<details >
266275 <summary>🤖 <strong>extract(...)</strong></summary>
267276
268- Extract specific information from websites using AI-powered natural language processing.
277+ Extract specific information from websites using AI-powered natural language processing with OpenAI .
269278
270279``` python
271- - `query` : Natural language query containing what to extract and from which URL (required)
280+ - `query` : Natural language query describing what to extract (required)
281+ - `url` : Single URL or list of URLs to extract from (optional - if not provided, extracts URL from query)
282+ - `output_scheme` : JSON Schema for OpenAI Structured Outputs (optional - enables reliable JSON responses)
272283- `llm_key` : OpenAI API key (optional - uses OPENAI_API_KEY env variable if not provided)
273284
274- # Returns: Extracted content as string with metadata attributes
285+ # Returns: ExtractResult object ( string-like with metadata attributes)
275286# Available attributes: .url, .query, .source_title, .token_usage, .content_length
276287```
277288
0 commit comments