Proper meta tag scrape method

Hi, i am trying to use a scrape sensor to get the content of the <meta> tag in the website. the code on the site reads:

<meta property="product:availability" content="in stock">

how do i get the content part using the scrape sensor? i have tried this, and it doesn’t work:

select: "meta [property=product:availability]"

is this even possible with the scrape sensor? thanks in advance!

It’s the ‘attribute’ section in the scrape sensor. The select will be “meta”

sensor:
  - platform: scrape
    resource: https://www.home-assistant.io
    select: "meta"
    attribute: "content"

Here’s an example. I scraped a wikipedia entry with the meta select. Here is the output:

URL="https://en.wikipedia.org/wiki/List_of_game_engines"
# This is the select line you will use in the config
SELECT="meta"
ATTR="content"
# You may need to use a template after the fact...
INDEX=3


*************** Output of SELECT: **************
 index[0]:  <meta charset="utf-8"/>
 index[1]:  <meta content="" name="ResourceLoaderDynamicStyles"/>
 index[2]:  <meta content="MediaWiki 1.35.0-wmf.27" name="generator"/>
 index[3]:  <meta content="origin" name="referrer"/>
 index[4]:  <meta content="origin-when-crossorigin" name="referrer"/>
 index[5]:  <meta content="origin-when-cross-origin" name="referrer"/>
**************
ATTR ('content') of index 3 = origin

Thank you, ‘attribute’ is what i was looking for. i’ve actually managed to get the content value i need without the INDEX:

example html:

<meta property="product:availability" content="in stock">

configuration.yaml:

select: "meta[property='product:availability']"
attribute: "content"
1 Like

Index 100% depends on the result of the scrape. If that select happened to return a couple different matches, you’d use index to pick which one you wanted.