How can I access META elements using the Custom API Toolkit?

The Custom API Toolkit makes it easy to access all elements on a page, including all META elements.

A common META element may look like this:

<meta property="og:title" content="Supreme Court Bolsters Gay Marriage With Two Major Rulings" />

When creating our rule, the first step is to create a CSS selector with the proper syntax to identify the specific meta property, og:title: meta[property=og:title]

Once that’s done, you’ll also need to specify the attribute you want to extract. In most cases this is the content attribute:

With that, your field should now be populated with the contents of the meta tag you specified.

Additional notes:

  • Did you know our Automatic APIs┬ácan automatically return all meta elements found on a page using the fields=meta parameter? Read more in our Documentation.
  • You can use the above syntax or attribute filters to extract nearly any other tag on a page. A src attribute will return the source URL of an image file, and the href attribute will return an anchor tag’s link location. div[itemprop=author] will retrieve any div elements that have an itemprop attribute of “author.”