#!/bin/bash
export A
for A; do
	echo "$A" >> links.$$
	DOC=`wg -q -O- "$A"`
	LINKS=`echo "$DOC" | htmllinks | grep -i '\.\(jp\|mp\|avi\|wmv\|asx\)' | relurl "$A"`
	if [ -z "$LINKS" ]; then
		LINKS=`echo "$DOC" | htmlimages | relurl "$A"`
	fi
	if [ -n "$LINKS" ]; then
		echo "$LINKS"
		echo "$LINKS" | wgcall
	fi
done
