Daddy, where is my formula?
Chase is only 20 months old, but he eats a lot… Well, he got a fat father, who can I blame… - -|||
Baby formula is always a hard thing to get in Australia as the producer is not able to supply enough to all Asian countries… (No blame here…)
Not many ways that we can get the formula:
- Chinese Daigou shop
- $37 per can, average $7 more than retail price
- Supermarket (Coles, WWS, etc…)
- Always out of stock
- Online (Mum’s store)
- 1 can per order with $10 postage fee = $30 + $10 even more expensive than Daigou shop
So do it in golang with basic operations…
- Find API for checking the stock level
- Call API to get result
- Sort JSON data
- Operate with data
Find API
Web page: https://www.woolworths.com.au/shop/productdetails/7211/aptamil-profutura-toddler-formula-stage-3
By clicking the Check stock in our stores
to find out if it’s purchasable.
With Chrome Dev Tool, the API url can be found out here: https://www.woolworths.com.au/apis/ui/product/7211/Stores?IncludeInStockStoreOnly=false&Latitude=-33.7038507&Longitude=151.1087877&Max=5
- In url
7211
: product id - IncludeInStockStoreOnly: limited result
- Latitude & Longitude: Location
- Max: limited result
Call API
Call API with golang by using http.Get
:
|
|
Result:
|
|
Analysis Data
To analysis JSON data, we need to declare the data structure based on JSON result first:
|
|
Then use json encoder to help analysis data:
|
|
Inside the if
part, we can simply put more actions: like email
, sms
, etc… to notify users.
Anyway, by using AWS lambda + SNS service, we are able to get the notification easily…
It’s a good start with golang from useful project, family side… ~ at least Chase got formula…