Scrape specific text within Selection

I have a web scraper setup using the HA scrape tool and it does connect and scrape the data but unfortunately too much. I am looking to extract the lat/long of a ship while underway.

My output from the scrape is

The current position of US WARSHIP 22 is at North America West Coast (coordinates 32.35192 N / 118.76818 W) reported 1 min ago  by AIS.     The vessel is  sailing at a speed of 8.0 knots.

There is (coordinates xx.xx – I am thinking I can filter from that? Not sure how to do that.

Any suggestions? Thank you.

  - platform: scrape
    name: KCT_GPS
    resource: https://www.vesselfinder.com/vessels/US-WARSHIP-22-IMO-0-MMSI-368872000
    select: "p.text2"
    headers:
      User-Agent: Mozilla/5.0

EDIT: I should read better :slight_smile:
The coordinates are also shown elsewhere
image

btw… there are also (free) API providing JSON output allowing to load lat/lon as an attribute…but you have to look for them yourselves and see if they match your need

I sent a request to this website requesting access. Is that what you are referencing? Whatever is easiest in this case :rofl:

Not sure which website as there are more so it seemed … but since I am not (that) interested…did not look further.
If you want to use the sensor for a position on a map (e.g. map card) then the lat+lon in the attributes would be sufficient, hence json is more efficient, one rest sensor and 'done.
However, with the scrap you can do this too but…you need 1 sensor for lat, 1 sensor for long and 1 sensor to bring the two together…not my style if (free) alternatives exist :slight_smile:

1 Like