Scrape sensor not working for site but bs4 does

I have several scrape sensors to get fuel prices. One of them is

https://www.tango.nl/stations/tango-capelle-aan-den-ijssel-hoofdweg

The scrape sensor looks like this:

- platform: scrape
  resource: "https://www.tango.nl/stations/tango-capelle-aan-den-ijssel-hoofdweg"
  name: Euro95 (Tango Hoofdweg)
  select: “div#euro95 div.pump_price span.price”
  scan_interval: 3600  # be nice; once per hour only

This returns ‘None’:

2022-09-25 07:18:29.560 WARNING (SyncWorker_9) [homeassistant.components.scrape.sensor] Index 'None' not found in sensor.euro95_tango_hoofdweg
2022-09-25 07:18:29.561 DEBUG (SyncWorker_9) [homeassistant.components.scrape.sensor] None

I am certain that the select is correct, since when I run a simple Python script, it returns the proper output:

import requests
from bs4 import BeautifulSoup

URL = "https://www.tango.nl/stations/tango-capelle-aan-den-ijssel-hoofdweg"
page = requests.get(URL)
soup = BeautifulSoup(page.content, "html.parser")

results = soup.select("div#euro95 div.pump_price span.price")
print(results[0].string)

Output:

$ python3 tango.py
1.909

I’ve also created a dummy sensor with a select of "title" that should just get the page title, but that has the same results.

So what could possibly be wrong?

Not sure if this is just a copy&paste issue, but your double-quotes used here look different to the ones used around the URL: vs. "

You are my hero! I have completely overlooked this. I changed to straight double quotes and now the sensor is working.

1 Like