Skip to content

Instantly share code, notes, and snippets.

@ctrlcctrlv
Created July 20, 2023 16:18
Show Gist options
  • Save ctrlcctrlv/c2139cf1a6bc09c1857572a392dbda1a to your computer and use it in GitHub Desktop.
Save ctrlcctrlv/c2139cf1a6bc09c1857572a392dbda1a to your computer and use it in GitHub Desktop.
download_fiverr_inbox.sh — ymmv!
#!/bin/bash
# make cookies and csrf files
# call w/timestamp of most recent msg
URL="https://www.fiverr.com/inbox/contacts/$TARGET_USER/load_more"
FILE_COUNTER=0
function fetch_messages {
TIMESTAMP=$1
RESPONSE=$(curl -s "$URL?from_timestamp=$TIMESTAMP" \
-H 'authority: www.fiverr.com' \
-H 'accept: application/json' \
-H 'accept-language: en-US,en;q=0.9,es-419;q=0.8,es;q=0.7' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'cookie: '"$(cat cookies)" \
-H 'dnt: 1' \
-H 'ect: 4g' \
-H 'fvrr-page-ctx-id: b4ad38d967efdd5a8153ef6aac1e9476' \
-H 'pragma: no-cache' \
-H "referer: https://www.fiverr.com/inbox/$TARGET_USER" \
-H 'sec-ch-ua: "Chromium";v="115", "Not/A)Brand";v="99"' \
-H 'sec-ch-ua-full-version: "115.0.5790.90"' \
-H 'sec-ch-ua-full-version-list: "Chromium";v="115.0.5790.90", "Not/A)Brand";v="99.0.0.0"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-model: ""' \
-H 'sec-ch-ua-platform: "Linux"' \
-H 'sec-ch-ua-platform-version: "6.4.0"' \
-H 'sec-fetch-dest: empty' \
-H 'sec-fetch-mode: cors' \
-H 'sec-fetch-site: same-origin' \
-H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36' \
-H 'x-csrf-token: '"$(cat csrf)" \
-H 'x-requested-with: XMLHttpRequest' --compressed)
MESSAGES=$(jq '.messages' <<< "$RESPONSE")
[[ $MESSAGES =~ "[]" ]] && return
FIRST_CREATED_AT=$(jq '.[0].createdAt' <<< "$MESSAGES")
FILE_COUNTER=$((FILE_COUNTER+1))
if [[ $MESSAGES != "null" ]]; then
FILENAME=$(printf "$TARGET_USER_%04d.json" $FILE_COUNTER)
echo $RESPONSE > $FILENAME
fetch_messages $FIRST_CREATED_AT
echo $FIRST_CREATED_AT
fi
}
fetch_messages $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment