#! /bin/bash 
# Last edited on 2016-05-08 22:26:01 by stolfilocal

usernum="$1"; shift;  # Bitcointalk user number.
username="$1"; shift;  # Bitcointalk user name (with "_" in place of blanks).
ip="$1"; shift;  # First page number.
fp="$1"; shift;  # Last page number.

profurl="https://bitcointalk.org/index.php?action=profile"

today=`date +'%Y-%m-%d-%H%M%S'`
ds=20; # Posts per page.

sk=$(( ( ${ip} - 1 ) * ${ds} ));  # Post skip index.
while [[ ${ip} -le ${fp} ]]; do
  uk=$(( ${sk} + ${ds} - 1 ))
  xsk=`printf "%05d" "${sk}"`
  xuk=`printf "%05d" "${uk}"`
  ofile="${username}/${today}-posts-${xsk}--${xuk}.html"
  echo "fetching ${ofile}" 1>&2 
  wget -nv "${profurl};u=${usernum};sa=showPosts;start=${sk}" -O "${ofile}"
  sleep 5
  sk=$(( ${sk} + ${ds} ))
  ip=$(( ${ip} + 1 ))
done
