From 469143445f6ef32b7dff34a755f1464068db322b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= <john@ankarstrom.se>
Date: Sun, 22 Nov 2020 18:54:58 +0100
Subject: Add 'blp' tool

This script retrieves the phone number associated with a Blocket.se ad.
---
 blp | 11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100755 blp

(limited to 'blp')

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
-- 
cgit v1.2.3