Element attribute selector

Examples

  • title
  • data-id
  • data-src
  • aria-label
  • content from a meta element

Choose an attribute

  1. Create or edit an Element Attribute selector.
  2. Select the target element with the selection tool, or enter its CSS selector manually.
  3. Click the Attribute name field.
  4. Select the required attribute from the dropdown. Web Scraper lists the attributes available on the selected element.

For example, if the selected element contains <div class="rarity-rating" data-rating="3">, the available attributes include class and data-rating. Choose data-rating to extract the value 3.

If the attribute you need is not shown, confirm that the selected element actually contains that attribute in the current page state. The general selection-tool HTML preview can help identify which element contains the required value.

Extract attributes from non-visible elements

Some useful attributes are stored in elements that cannot be targeted with the point-and-click tool because they are not visible in the rendered page. In these cases, create the selector manually.

For example, a page may define its canonical social URL in a meta element:

<meta property="og:url" content="https://example.com/products/widget-123">

To extract the URL, enter meta[property="og:url"] in the Selector field and set Attribute name to content.

Manual creation is not limited to Element Attribute selectors, but it is especially common with them because metadata and custom data values are frequently stored outside the visible page content.

Configuration

  • Selector - CSS selector for the source element.
  • Attribute name - HTML attribute to extract. After an element has been selected, click this field to view the attributes available on that element.
  • Multiple type - Defines how several matched values are returned.
  • Column count - Maximum output columns when values are split across columns.

Validation

Confirm that the attribute exists on every representative element. Missing attributes return empty values and can reduce field population even when the selector itself matches.

Related

Related videos