Fetch a single element with get_by_prompt
You can use the get_by_prompt
method to locate one or more elements from a web page by passing context, a prompt describing the element you're looking for. You can use this element to automate workflows and interact with web sites by simulating clicking on buttons, filling out form fields, and scrolling.
Overview
This guide shows you how to return an element with get_by_prompt
and how to use it in your scripts to interact with web elements.
Pass a prompt to get_by_prompt
Access an element returned by get_by_prompt
get_by_prompt
returns a Python object you can use to interact with the element on the page. You can access the element as if they were the fields of this response object.
Conclusion
get_by_prompt
is the proper method to use when you want to interact with a single element on a page. If you need to access multiple elements or want to make one call to return multiple locators, use the query_elements
method instead.
Related content
Example Script
This example shows how to use AgentQL's
get_by_prompt
method to retrieve an element and interact with it.Fetch a collection of elements with
query_elements
How to use AgentQL's
query_elements
method to locate more than one element from a web page and perform automations with them.Scraping data with
query_data
Learn how to use the
query_data
method to scrape and extract structured data from a website using AgentQL.