summaryrefslogtreecommitdiff
path: root/blp
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2020-11-22 18:54:58 +0100
committerJohn Ankarström <john@ankarstrom.se>2020-11-23 00:08:13 +0100
commit469143445f6ef32b7dff34a755f1464068db322b (patch)
tree7eda3a9970a65f7b4cab796b5a66d8d384f3e528 /blp
parent3537be9e7c578f8ca84e9d420044654577706a11 (diff)
downloadweb-469143445f6ef32b7dff34a755f1464068db322b.tar.gz
Add 'blp' toolblocket
This script retrieves the phone number associated with a Blocket.se ad.
Diffstat (limited to 'blp')
-rwxr-xr-xblp11
1 files changed, 11 insertions, 0 deletions
diff --git a/blp b/blp
new file mode 100755
index 0000000..8ad30c4
--- /dev/null
+++ b/blp
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+sed -n 's/ID: //p' |
+while read id
+do
+ # Retrieve authorization token
+ tok=`curl -s "https://www.blocket.se/annons/a/b/$id" | awk '/id="initialState"/ {getline; print}' | jq -r .authentication.bearerToken`
+
+ # Retrieve phone number
+ curl -s -H "authorization: Bearer $tok" "https://api.blocket.se/search_bff/v1/content/$id/phone_numbers" | jq -r .phone_number
+done