-
-
Save killerbees19/2ba7041d687b59cef7bd6da08c887b2c 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 | |
######################################################################## | |
username="urlencoded username" | |
sid="ncf_cookieHash value" | |
token="SECURITY_TOKEN variable" | |
agent="HTTP User-Agent value" | |
######################################################################## | |
curl -s -L 'https://forum.netcup.de/system/search/' -H "Cookie: ncf_cookieHash=$sid" -H "User-Agent: $agent" | grep -F '> ' > /tmp/forums.html | |
if [[ ! -s /tmp/forums.html ]] | |
then | |
echo "ERROR: Could not fetch forum IDs!" >&2 | |
exit 1 | |
fi | |
while IFS= read -r line | |
do | |
id=$(sed -r 's/^.+value="([0-9]+)".+$/\1/' <<< "$line") | |
title=$(sed -r 's/^.+>( )+(.+)<.+$/\2/' <<< "$line") | |
c=0 | |
p=" " | |
n=$(date +%s) | |
e=$(date +%Y) | |
for y in $(seq 2008 "$e") | |
do | |
sleep 1 | |
start="$y-01-01" | |
end="$y-12-31" | |
if [[ "$(date -d "$end" +%s)" -gt "$n" ]] | |
then | |
end="$(date -d @"$n" +%Y-%m-%d)" | |
fi | |
echo "cURL: [$(printf F%02d "$id")] $start - $end" >&2 | |
result=$(curl -s -L 'https://forum.netcup.de/system/search/' -H "Cookie: ncf_cookieHash=$sid" -H "User-Agent: $agent" -H 'Content-Type: application/x-www-form-urlencoded' --data-raw "q=&username=$username&nameExactly=1&startDate=$start&endDate=$end&sortField=time&sortOrder=ASC&types%5B%5D=com.woltlab.wbb.post&boardIDs%5B%5D=$id&t=$token") | |
if ! grep -F 'title="Kontrollzentrum"' <<< "$result" >/dev/null | |
then | |
echo "ERROR: Not logged in!" >&2 | |
exit 1 | |
fi | |
counter=$(grep -F contentHeaderDescription <<< "$result" | cut -d '<' -f 2 | cut -d '>' -f 2 | egrep -o ' insgesamt [0-9.]+\.' | sed -r 's/[^0-9]+//g') | |
if [[ "$counter" -gt 0 ]] | |
then | |
((c+=counter)) | |
fi | |
if [[ "$counter" -gt 1000 ]] | |
then | |
p=">=" | |
fi | |
done | |
echo "$p $(printf %4d "$c") Beiträge: [$(printf F%02d "$id")] $title" | |
done < /tmp/forums.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment