Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function dl {
- fold=$(echo "${1}" | perl -lane '($fold) = $_ =~ /thread\/(\d+)/; print $fold' | head -n1)
- mkdir -p "${fold}"
- echo -n "Downloading.."
- curl -s "${1}" | perl -lane \
- 'BEGIN {
- sub dl {
- my $str = shift;
- (my $URL) = $str =~ /href=\"\/\/(.+?)\"/;
- (my $title) = $str =~ /\<a title\=/ ? $str =~ /title=\"(.+?)\"/ : $str =~ /target=\"_blank\">(.+?)\<\/a\>/;
- $title =~ s/\s+/_/g;
- print "$URL $title";
- }
- }{
- (my @a) = $_ =~ /div class=\"fileText\"(.+?)<\/div>/g;
- foreach $a (@a){
- &dl($a)
- }
- }' | while read URL title; do
- if [[ ! -e "${fold}/${title}" ]]; then
- curl -s "${URL}" > "${fold}/${title}"
- echo -n "."
- fi
- done
- echo
- }
- ### Usage:
- # dl http://boards.4chan.org/b/thread/########
Add Comment
Please, Sign In to add comment