我想从多个网站存档集合。我希望能够维持他们是某种组织。所以将它们存储在镜像目录结构中是理想的。下面是我尝试镜像网站下载特定的文件类型与BASH
wget -m -x -e robots=off --no-parent --accept "*.ext" http://example.com
当使用“-m”选项它有它去多远任何限制吗? (将它徘徊断了的网站?永远继续?)如果是这样,是它更好地使用
wget -r -x -e robots=off --no-parent --accept "*.ext" --level 2 http://example.com
这是做到这一点的最合理的方式是什么?我知道“wget”有一个--spider选项,它是否稳定?
编辑
这是我已经找到了解决办法。
我正在查找的文件被标记并存储在服务器端的单个dir
中。当尝试变化wget
。我能够获得链接和各种文件的结构,但是我一直在使用循环运行链接时遇到问题。所以我想出了这个工作。它有效,但速度很慢。有关如何提高效率的任何建议?
的网站&文件,我试图让
home
├──Foo
│ ├──paul.mp3
│ ├──saul.mp3
│ ├──micheal.mp3
│ ├──ring.mp3
├──Bar
├──nancy.mp3
├──jan.mp3
├──mary.mp3
所以首先我创建的结构, 与我想
taglist.txt
foo
bar
文件的标签文件
剧本
#!/bin/bash
#this script seems to work until the download part
URL="http://www.example.com"
LINK_FILE=taglist.txt
while read TAG; do
mkdir "$TAG"
cd "$TAG"
# Get the URLs from the page
wget -q $URL/$TAG -O - | \tr "\t\r\n'" ' "' | \grep -i -o '<a[^>]\+href[ ]*=[ \t]*"\(ht\|f\)tps\?:[^"]\+"' | \sed -e 's/^.*"\([^"]\+\)".*$/\1/g' > tmp.urls.txt
# Clean and sort URLs
grep -i 'http://www.example.com/storage_dir/*' tmp.urls.txt | sort -u > tmp.curls.txt
# Download the page with the URL
while read TAPE_URL; do
#wget -r -A.mp3 $TAPE_URL
wget -O tmp.$RANDOM $TAPE_URL
done <tmp.curls.txt
# Find all the .mp3 links in the files
grep -r -o -E 'href="([^"#]+)[.mp3]"' * | cut -d'"' -f2 | sort | uniq > $TAG.mp3.list
# Clean Up
rm tmp.*
# Download the collected URLs
wget -i $TAG.mp3.list
cd ..
done <"$LINK_FILE"