[code]#!/bin/bash#创建临时文件temp_file=/opt/leo/testif [ ! -f $temp_fiile ];thentouch $temp_filefi#下载页面文件至临时文件curl 网页 > $temp_file#获取网页标题dir=`grep \"\\(title\\).*\\1\" /opt/leo/test | tr -s \' \' | grep \"\\(title\\).*\\1\" /opt/leo/test | tr -s \'\' | cut -d \'>\' -f 2 | cut -d \'[\' -f1`date=`date \'+%Y-%m-%d\'`dir_name=\"$date-$dir\"echo \"$dir_name\"if [ ! -d $dir_name ];thenmkdir $dir_nameficount=`ls $dir_name | wc -l `if [ $count -ne 0 ];thenecho \"目录不为空\"exitfidir_path=/opt/leo/$dir_namecd $dir_path#截取下载地址grep \"http://.*jpg\" $temp_file | tr -s \'(\' \'\\n\' | tr -s \')\' \'\\n\' | grep \"http.*jpg\" > temp_file2sed \"s/\'//g\" temp_file2 > temp_file3wget -i temp_file3ls
网页字段格式: