blob: 0941da83e7577000aab77fbf6380417dd7fbfd92 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
#!/bin/sh
# Perform a search on Blocket.se (API v6, Nov 2020)
test -z "$1" && { echo usage: $0 query 1>&2; exit 1; }
# Format query string
q=`printf '%s\n' "$1" | sed 's/ /%20/g'`
# Retrieve authorization token
tok=`curl -s "https://www.blocket.se/annonser/hela_sverige?q=$q" | awk '/id="initialState"/ {getline; print}' | jq -r .authentication.bearerToken`
# Retrieve search results
curl -s -H "authorization: Bearer $tok" "https://api.blocket.se/search_bff/v1/content?lim=40&q=$q&st=s&include=all&gl=3&include=extend_with_shipping"
|