# Extract price from website

**URL:** <https://community.homey.app/t/extract-price-from-website/85113>\
**Category:** Questions & Help\
**Created:** [July 23, 2023, 9:26am UTC](https://community.homey.app/t/extract-price-from-website/85113 "2023-07-23T09:26:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![CaptainVoni](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/captainvoni/32/3549_2.png) [@CaptainVoni](https://community.homey.app/u/CaptainVoni)\
**Post date:** [July 23, 2023, 9:26am UTC](https://community.homey.app/t/extract-price-from-website/85113/1 "2023-07-23T09:26:32Z")

</div>

Any suggestions how I can extract a price from a website?

Currently I’m trying to figure out how I could access the “Einspeisetarif” (feed-in tariff) for the aWattar Sunny tariff from this site: [SUNNY - Ihr Solarstrom für Österreich!](https://www.awattar.at/tariffs/sunny)  
It’s the “8,291 Cent/kWh”.

I thought I could just make a HTTP GET request and pass the result to Homey Script, where I could extract it with some string manipulation (regex preferable, but indexof/substring would also suffice). But it seems that no string functions are accessible in Homey Script. Am I mistaken?

Any other ideas or hints what I could try? Thanks in advance!

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [July 23, 2023, 5:24pm UTC](https://community.homey.app/t/extract-price-from-website/85113/2 "2023-07-23T17:24:54Z")

</div>

```auto
// https://www.awattar.at/services/api/v1/marketdata 
// https://api.awattar.at/v1/marketdata

const res = await fetch("https://api.awattar.at/v1/marketdata");
if (!res.ok) {
throw new Error(res.statusText);
}

// Get the body JSON
const results = await res.json();

//console.log("RESULTS=", results,"\n ----------------" );

console.log("Data marketprice =", results.data[0].marketprice, results. Data[0].unit);

return (true );

```

This is what you are looking for?

---

<div class="post-metadata">

**Author:** ![CaptainVoni](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/captainvoni/32/3549_2.png) [@CaptainVoni](https://community.homey.app/u/CaptainVoni)\
**Post date:** [July 23, 2023, 5:38pm UTC](https://community.homey.app/t/extract-price-from-website/85113/3 "2023-07-23T17:38:25Z")

</div>

That gets the market data that is used for the Hourly tariff, but not the price for the Sunny feed-in tariff.  
The first can be retrieved via the Power by the Hour app, but I don’t have a solution for the second. As far as I know, there is no API available for the feed-in tariff.

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [July 23, 2023, 5:47pm UTC](https://community.homey.app/t/extract-price-from-website/85113/4 "2023-07-23T17:47:47Z")

</div>

Sory, think I didn’t read very well…

> [@CaptainVoni](#):
>
> it seems that no string functions are accessible in Homey Script. Am I mistaken?

String functions are available, its plane JavaScript.

---

<div class="post-metadata">

**Author:** ![CaptainVoni](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/captainvoni/32/3549_2.png) [@CaptainVoni](https://community.homey.app/u/CaptainVoni)\
**Post date:** [July 24, 2023, 7:54am UTC](https://community.homey.app/t/extract-price-from-website/85113/5 "2023-07-24T07:54:33Z")

</div>

Thanks, I got it working now.

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [July 24, 2023, 10:38am UTC](https://community.homey.app/t/extract-price-from-website/85113/6 "2023-07-24T10:38:23Z")

</div>

Great it’s working, did you extract it from the html page?

---

<div class="post-metadata">

**Author:** ![CaptainVoni](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/captainvoni/32/3549_2.png) [@CaptainVoni](https://community.homey.app/u/CaptainVoni)\
**Post date:** [July 24, 2023, 11:12am UTC](https://community.homey.app/t/extract-price-from-website/85113/7 "2023-07-24T11:12:32Z")

</div>

Yes, directly from the website. Just extract the first “xx,xxx Cent/kWh” I find in the body. I asked them if they could make they price available through their API, but haven’t got an answer yet.
