> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/automate-en/action-guides/element/get-element-attribute.md).

# Get element attribute

This action helps you "extract" hidden information within an element on the web page and store it in a variable for later use.

* Purpose: For example, you can get the image path from the `src` attribute, or get the link from the `href` attribute of an anchor tag, or get the input value in the `value` field.
* Simple understanding: Each component on the web has accompanying "attributes" (like information labels). This command helps you read and "copy" information from that label to save it.

#### Explanation of configuration parameters:

* Element XPath: The XPath identifier path of the element containing the attribute to be retrieved on the web interface.
* Attribute name: The name of the attribute from which you want to extract data.
  * *Example structure*: `<tag attribute_name="attribute_value">Text</tag>` ➔ You just need to fill in `attribute_name` in this field to retrieve `attribute_value`.
* Output variable: The variable name to store the string value of the attribute after successful retrieval.

#### Practical example: Scraping product image links based on actual images (Figure 5)

Based on the interface of the mobile phone store you are working on in the image, you want to scrape the image path of the Samsung Galaxy S6 phone for data storage or automatic posting to your shop.

Looking at the HTML source code table (red frame on the right of the image):

> Image tag structure: `<img class="card-img-top img-fluid" src="imgs/galaxy_s6.jpg" alt="">`

To get the image path string `imgs/galaxy_s6.jpg`, you will configure the action as follows:

* Element XPath: Enter the exact XPath pointing to that image tag, for example: `//div[@class="card h-100"]/a/img` (or use the syntax as in your image: `//div[@class='card h-100']//img`).
* Attribute name: Enter the word `src` *(This is the name of the attribute containing the file path of the image)*.
* Output variable: Name the output variable `imgUrl`.

Result: The system will find the image tag of the Samsung Galaxy S6, extract the string value in the `src` attribute, and directly load the value `imgs/galaxy_s6.jpg` into the variable `$imgUrl`. You can use this variable for actions like downloading the image or storing it in the backend.

<figure><img src="/files/cDQgl0jYTtpwv6W7qWKo" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/HOtcUQ2GuafiO39BW8FS" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gpmautomate.com/automate-en/action-guides/element/get-element-attribute.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
