Last active
October 2, 2018 07:30
-
-
Save mmatczuk/f1e081902c824a8ce4298db6d89e96af to your computer and use it in GitHub Desktop.
ScyllaDB endorsments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# This script loads all your connections from linkedin and for each connection | |
# tries to endorse ScyllaDB skill. Uses curl, grep and jq. | |
# | |
# To run it using Chrome: | |
# 1. Open https://www.linkedin.com in a browser and login | |
# 2. Press Ctrl+Shift+I to open Developer Tools | |
# 3. Go to Network pane | |
# 4. In Filter box write `track` | |
# 5. Press F5 to reload the page | |
# 6. Click on one of the requests | |
# 7. Scroll down to `Request Headers` | |
# 8. Copy headers `cookie` and `csrf-token` values to COOKIE and CSRF variables below | |
# 9. Save and run the script | |
COOKIE='<put your cookie here>' | |
CSRF='<put your csrf-token here>' | |
COUNT=1000 # if you have more connections than that - increase | |
CONTACTS=(`curl -sS --compressed -o /dev/stdout \ | |
-H 'accept-encoding: gzip, deflate, br' \ | |
-H 'accept: application/vnd.linkedin.normalized+json+2.1' \ | |
-H "cookie: ${COOKIE}" \ | |
-H "csrf-token: ${CSRF}" \ | |
-H 'authority: www.linkedin.com' \ | |
"https://www.linkedin.com/voyager/api/relationships/connections?count=${COUNT}" \ | |
| jq -r '.included[] | select(.publicIdentifier != null) | .publicIdentifier, .entityUrn'`) | |
len=$((${#CONTACTS[@]}/2)) | |
e=0 | |
for ((i = 0 ; i < len ; i++ )); do | |
name="${CONTACTS[2 * i]}" | |
urn="`cut -d: -f4 <<< ${CONTACTS[2 * i + 1]}`" | |
s=`curl -sS -o /dev/null -w "%{http_code}" \ | |
-H 'origin: https://www.linkedin.com' \ | |
-H 'content-type: application/json; charset=UTF-8' \ | |
-H 'accept-encoding: gzip, deflate, br' \ | |
-H 'accept: application/vnd.linkedin.normalized+json+2.1' \ | |
-H "cookie: ${COOKIE}" \ | |
-H "csrf-token: ${CSRF}" \ | |
-H 'authority: www.linkedin.com' \ | |
--data-binary "{\"skill\":{\"entityUrn\":\"urn:li:fs_skill:(${urn},1)\",\"name\":\"ScyllaDB\"}}" \ | |
"https://www.linkedin.com/voyager/api/identity/profiles/${urn}/normEndorsements"` | |
if [ "${s}" == "201" ]; then | |
e=$((e+1)) | |
echo " https://www.linkedin.com/in/${name}" | |
fi | |
done | |
echo "Handled ${len} connections, endorsed ${e}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment