extract_text

def extract_text(
    self,
    element_description: str,
    use_vision: bool = False
) -> str:
element_description
string
required

Natural language description of the element to extract text from.

use_vision
boolean
default:
"False"

Whether to use vision to find the text. Helpful if Simplex struggles to find the text when use_vision = False, otherwise not necessary.

return
str

Extracted text string(s) within the requested element. If there are multiple, separate text chunks within the element (i.e. the element description is all financial headlines on a page), this chunks will be separated by newline characters.

Sample Usage

In this example, we’re building a script to purchase 3D models from CGTrader (a 3D design marketplace) for a synthetic data project. Since we want to use this asset for creating synthetic data, we need to check if the license allows AI use.

Here’s a sample product page (license highlighted in green):

We can extract the license text to check if it allows AI use.

from simplex import Simplex

simplex = Simplex(api_key="your_api_key")
simplex.create_session()
simplex.goto("https://www.cgtrader.com/3d-models/aircraft/commercial-aircraft/boeing-787-8-5f56fa4f-4ca5-42b8-9ffa-154fb2215928")

succeeded, text = simplex.extract_text("type of license")
if succeeded and "no ai" not in text.lower():
    simplex.click("add to cart")