So I’ve had to create a bash script to curl a website and trim the output
it runs and outputs the following: Friday 6th May, black
Id like to only query the website once - so trying to avoid running a similar request twice
so far I’ve tried the below, now I am new and all of the below is in the configuration.yaml - not sure if that’s where I should put the “Template” part?
for testing I outputted the Curl request to temp file so that I could test this with out querying the website too often. and set it to 60 seconds so I could make changes without restarting services
#!/usr/bin/env bash
#curl -s -X POST "https://app.ipswich.gov.uk/bin-collection/" --data-urlencode "txt_street=kings way” --data-urlencode "but_submit=Find now" | grep -E "This week,|Next week,*" | sed -E 's/<[^>]*>//g; s/ bin[s]* will be emptied\.//; s/ your //g; s/^.*on //; s/[0-9]+, */,/g' | sed 's/ ,/,/g' | jq -nR '[inputs | split(",") | {"date": .[0], "type": .[1]}]'
#Note I struggled with the output as Jason so switched to flat output and also used a file htmltest to do testing of the Grep / Sed Commands.
cat htmltest | grep -E "This week,|Next week,*" | sed -E 's/<[^>]*>//g; s/ bin[s]* will be emptied\.//; s/ your //g; s/^.*on //; s/[0-9]+, */,/g' | sed 's/ ,/,/g'
Originally I wanted to display a tile with the Day of the week and the colour for this weeks collection and the day and could for next weeks. but it got complicated so resorted to just this weeks data.