Selectors

jQuery

Are you familiar with jQuery selectors? If so, you already know how to grab almost any element from an HTML page!

Wether you are familar with jQuery or not, our selector syntax is simple to understand. We'll outline some of the most popular ways to grab elements from a page. Keep in mind there are many different ways to combine selectors. We encourage you to experiment with selectors using the Playground feature found within the Dashboard.

What selectors you use will largely depend on the HTML of the host site you're pulling data from. You'll need to inspect the elements on the page to observe HTML tags and find usable class names and ID selectors.

Element Name

The element name selecotr allows you to select HTML elements by name. For example, you could select all links on a page by selecting <a> HTML elements.

Element ID

The ID selector enables you to select any element by it's ID. Valid ID's should be unique so the ID selector would be a good way to target a single element's value.

Element CSS Class

The CSS selector is similar to the element selector, but an HTML page can contain multiple CSS classes that are the same.

If a class is used on multiple elements you should combine the class name with the Repeating Elements method of looping.

You can also combine multiple CSS classes in a single selector to get more selective. For instance, if a single element on a page has three classes, you can target the one element that has all three classes.

Element Attributes

Anything API's selectors allow you to utlizie attributes in two different ways. One, you can use attributes to select elements. But you can also get the values of any attribute and return that in your JSON response.

Use the following syntax to select an element by it's attribute. This example would select an image tag with an alt attribute of "banana". 🐵

To read and return the value of an element's attribute do the following. This example will select the title attribute from an element with the ID "aUniqueID".