From 62b7f946f27af709a92163e86bf87e2e4e2ebf71 Mon Sep 17 00:00:00 2001 From: Shihaam Abdul Rahman Date: Sat, 11 Feb 2023 02:03:11 +0500 Subject: [PATCH] fix 000002 issue --- .cache | 15 +++++++++++++++ scrap.sh | 8 +++++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 .cache diff --git a/.cache b/.cache new file mode 100644 index 00000000..34488e16 --- /dev/null +++ b/.cache @@ -0,0 +1,15 @@ +HTTP/2 200 +date: Fri, 10 Feb 2023 21:02:17 GMT +content-type: application/json; charset=utf-8 +etag: W/"109gcwx93k0as" +vary: Accept-Encoding +x-do-app-origin: aa8d031b-d5a9-4f77-90a3-fd4b557dee6b +cache-control: private +x-do-orig-status: 200 +cf-cache-status: DYNAMIC +report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=%2FxQszgOUyalvUN5CwvAZmko%2FX0lifqQd3ijgc%2FaDExumc2M3Yu%2BBdLYR4Lh6ggIzDBc6FzsL7xs%2BgTM0j5MMUb1cwj8mFkc8bCRTD7aOA8USJXkwuZ8TH7otU%2B5P%2FYKoW1leKvo%3D"}],"group":"cf-nel","max_age":604800} +nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800} +server: cloudflare +cf-ray: 7977c8ef9c508802-SIN + +{"id":5,"nic":"A000018","name":"cfInwH udwmcHwa","name_en":"Ahmed Haneef","dob":"1977-08-01T00:00:00.000Z","gender":"M","house_name":"rWTcsuain","house_name_en":"New Star","island_name":"elWm","island_name_en":"Male'","atoll":"k","atoll_en":"K","constituency":"T9","district_en":"Galolhu","block_no":"140","created_at":"2023-02-03T14:12:32.901Z","updated_at":"2023-02-03T14:12:32.901Z"} \ No newline at end of file diff --git a/scrap.sh b/scrap.sh index 5bb78eba..29e27efc 100755 --- a/scrap.sh +++ b/scrap.sh @@ -1,11 +1,12 @@ #/bin/bash START_NID=$1 +NID=$START_NID END_NID=$2 FILENAME=A${1}-A${2}.json while [ "$START_NID" -le "$END_NID" ]; do - echo Scraping: $START_NID # print - CONTENT=$(curl -si https://fikureggedhirun.com/api/fetch?nic=A$START_NID > .cache) # curl output with http headers and data + echo Scraping: $NID # print + CONTENT=$(curl -si https://fikureggedhirun.com/api/fetch?nic=A$NID > .cache) # curl output with http headers and data DATA=$(cat .cache | tail -n1) # get the json data from last line HTTP_STATUS=$(cat .cache | head -n1 | awk '{print $2}') # get the http code from first line @@ -14,7 +15,8 @@ do echo $DATA | tee -a $FILENAME printf "\n" | tee -a $FILENAME START_NID=$(echo $[$START_NID+1]) - sleep 5 + printf -v NID "%06d" $START_NID + sleep 1 else echo delaying sleep 1000