特定のパスを持つwgetイメージ

特定のパスを持つwgetイメージ

たとえば、特定のパスを持つ文書からのみ画像を取得したいとします。

example.com/uploads/287167/file_name.jpg

アップロード/番号/ファイル名のあるコンテンツのみをクロールします。

私は現在これをやっています:

wget http://example.com/news/36843 -q -O - | sed -n -e"s%^.*\(http://example.com/uploads/[0-9][^ \"\']*\.jpg\).*$%\1%p" | xargs wget -q

別の方法がありますか?

ベストアンサー1

これを行う方が簡単です。

wget http://example.com/news/36843 -q -O - \
  | grep -Eo 'http://example.com/uploads/[0-9]+/[^"]+\.jpg' \
  | wget -i -

の場合、-Ajpgファイルをフィルタリングできます。必要なパスをフィルタリングするには-I。ただし、再帰モードでのみ機能するため、必要なものよりも多くダウンロードできます。

wget http://example.com/news/36843 -r --level 1 -A jpg -I "/uploads/[0-9]*"

検証されていません。

おすすめ記事