Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

archiver

Name: Anonymous 2013-07-27 16:06

I know it's kind of shitty, but it gets the job done alright?



#!/bin/sh

script=`basename $0`
status=0
board=$1
num_threads=$2
delay=$3

if [ -z "${board}" -o -z "${num_threads}" ]
then
  echo "${script}: Usage: ${script} board num-threads [ delay ]"
  exit 1
fi

if [ -z ${delay} ]
then
  # 2 seconds is generous enough
  delay=2
fi

mkdir ${board}

wget https://dis.4chan.org/$;{board}/subject.txt
if [ $? -ne 0 ]
then
  echo "Couldn't get the subject page."
  exit 1
fi

# head gets the top num_threads threads
# sed extracts the thread number
head -n ${num_threads} subject.txt \
  | sed 's/[^<]*<>[^<]*<>[^<]*<>\([^<]*\)<>.*/\1/' \
  > threads.tt

# check the validity of the thread number. It should be all digits.
# this also protects against shell injection.
grep '^[0-9]\+$' threads.tt > wellformed-threads.tt
grep -v '^[0-9]\+$' threads.tt > non-wellformed-threads.tt

for thread in `cat wellformed-threads.tt`
do
  echo "Downloading thread ${board}/${thread}:"
  wget https://dis.4chan.org/read/$;{board}/${thread} -O ${board}/${thread}.html
  if [ $? -ne 0 ]
  then
    echo "Error downloading thread ${board}/${thread}" | tee -a errors.tt
  fi
  sleep ${delay}
done

if [ -s non-wellformed-threads.tt ]
then
  echo "These threads could not be downloaded because the subject was messed up."
  cat non-wellformed-threads.tt
  echo
  status=1
fi

if [ -s errors.tt ]
then
  echo "These threads could not be downloaded."
  cat errors.tt
  echo
  status=1
fi

exit ${status}

Name: Anonymous 2013-07-27 16:08

what the fuck shiiTchan!!![/sup]

${board}

${board}


${board}

Name: Anonymous 2013-07-27 16:09

www.anus.com/${board}

Name: Anonymous 2013-07-27 16:09


www.anus.com/$;{board}

Name: Anonymous 2013-07-27 16:10

Name: Anonymous 2013-07-27 16:14

remove the semi-colon on lines 23 and 44. shiichan can't handle urls with $ signs in them in a code body. That's so specific, what the fuck shiichan?


www.anus.com/$;
www.anus.com/$$;
www.anus.com/$$$;

Name: Anonymous 2013-07-27 21:38

I forgot to include example usage

If it is saved as download.sh:

# downloads the top 100 threads from /prog/, with
#    a delay of 3
download.sh prog 100 3

threads are saved a prog/ directory. Check errors.tt and non-wellformed-threads.tt for errors in downloading.

Name: Anonymous 2013-07-28 9:58

top 100 threads

xD

implying the threads are ordered by how good they are

Name: Anonymous 2013-07-28 20:51

>>8

lel i know. top 100 threads by latest bump time.

Name: Anonymous 2013-07-28 21:16

    I know it's kind of shitty, but it gets the job done alright?

That's what she said

Name: Anonymous 2013-07-28 21:17

check 'em

Don't change these.
Name: Email:
Entire Thread Thread List