AgentQL Query Introduction
The AgentQL query serves as the building block of your script. This guide shows you how AgentQL's query structure works and how to write a valid query.
Single term query
A single term query enables you to retrieve a single element on the webpage. Here is an example of how you can write a single term query to retrieve a search box.
List term query
A list term query enables you to retrieve a list of similar elements on the webpage. Here is an example of how you can write a list term query to retrieve a list of prices of apples.
You can also specify the exact field you want to return in the list. Here is an example of how you can specify that you want the name and price from the list of products.
Combining single term queries and list term queries
You can query for both single terms and list terms by combining the preceding formats.
Giving context to queries
There two main ways you can provide additional context to your queries.
Structural context
You can nest queries within parent containers to indicate that your target web element is in a particular section of the webpage.
Semantic context
You can also provide a short description within parentheses to guide AgentQL in locating the right element(s).
Syntax guidelines
Enclose all AgentQL query terms within curly braces {}
. The following query structure isn't valid because the term "social_media_links" is wrongly enclosed within parenthesis()
.
You can't include new lines in your semantic context. The following query structure isn't valid because the semantic context isn't contained within one line.