mvnic/scrap.sh
2023-02-11 01:25:05 +05:00

28 lines
538 B
Bash
Executable File

#/bin/bash
START_NID=$1
END_NID=$2
FILENAME=A${1}-A${2}.json
while true;
do
echo Scraping: $START_NID
CONTENT=$(curl -si https://fikureggedhirun.com/api/fetch?nic=A$START_NID > .cache)
DATA=$(cat .cache | tail -n1)
HTTP_STATUS=$(cat .cache | head -n1 | awk '{print $2}')
if [ "$HTTP_STATUS" = "200" ]
then
echo $DATA | tee -a $FILENAME
printf "\n" | tee -a $FILENAME
START_NID=$(echo $[$START_NID+1])
sleep 5
else
echo delaying
sleep 1000
fi
if [ "$END_NID" = "$START_NID" ]
then
exit 1
fi
done