From 3f889404d1c1789df4c4ccc0299e301806ea56e6 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 21 Aug 2020 15:45:32 +0300 Subject: [PATCH] getinfo: - check and use correct html2text Signed-off-by: HeshamTB --- getinfo | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/getinfo b/getinfo index 54a06a1..ffd76da 100755 --- a/getinfo +++ b/getinfo @@ -19,9 +19,22 @@ # along with stonks. If not, see . #read arg and get info from mubasher + +#check requirments +html2text=html2text +if ! command -v html2text &> /dev/null +then + if ! command -v html2text2 $> /dev/null + then + echo "Can't find html2text" + exit 1 + else + html2text=html2text2 + fi +fi raw=$(curl -s "https://english.mubasher.info/markets/TDWL/stocks/$1" | \ - html2text2 | \ + $html2text | \ sed -n '/Last update:/,$p' | \ - sed -n '/Stock Statistics/q;p') + sed -n '/Stock Statistics/q;p') && echo "scrapped $1" mkdir -p raw echo "$raw" > "raw/$1"