Created
November 17, 2021 16:05
-
-
Save NunoSempere/0959416ccf710a26974c8a95fb8431a6 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
## Defintions | |
fileName="list_of_users.txt" | |
fileNameResults="results.csv" | |
## Initialization | |
clear | |
rm -f "$fileNameResults" | |
echo "user, karma, wiki_edits" >> "$fileNameResults" | |
## Auxiliary function | |
function check_user(){ | |
user="$1" | |
base_url="https://forum.effectivealtruism.org/users" | |
user_url="$base_url/$user" | |
wget "$user_url" -O "user.html" -q | |
# tidy -m "user.html" > /dev/null 2>&1 | |
num_context=20 | |
karma="$(cat user.html | grep -E -o ".{0,20}karma.{0,20}" | head -1 | sed 's|.*title="||' | sed "s| karma.*||" )" | |
## karma=$(cat user.html | grep " karma" | head -1 | sed 's|.*title="||' | sed "s| karma.*||") | |
wiki_edits="$(cat user.html | grep -E -o ".{0,20}wiki edit.{0,20}" | head -1 | sed 's|.*title="||' | sed "s| wiki edit.*||")" | |
echo "$user: $karma karma, $wiki_edits wiki edits" | |
echo "$user, $karma, $wiki_edits" >> "$fileNameResults" | |
} | |
## Main body | |
while IFS= read -r line; do | |
check_user "$line" | |
# echo "$line" | |
done < "$fileName" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment