2012-01-11 14 views
6

ウェブサイトからすべての画像を高速かつ簡単にダウンロードする方法は何ですか?より具体的には、http://www.cycustom.com/large/ウェブサイトからすべての画像をダウンロードする最も簡単で簡単な方法

私はwgetやcurlのラインに沿って何かを考えています。

まず、私は現在、この作業をどのように達成するのか分かりません。次に、私はwgetかcurlが分かりやすい解決策を持っているかどうかを調べることに興味があります。ありがとう。

---更新@sarnold ---

ありがとうございます。私はそれもトリックをするだろうと思った。しかし、それはしません。

wget --mirror --no-parent http://www.cycustom.com/large/ 
--2012-01-10 18:19:36-- http://www.cycustom.com/large/ 
Resolving www.cycustom.com... 64.244.61.237 
Connecting to www.cycustom.com|64.244.61.237|:80... connected. 
HTTP request sent, awaiting response... 200 OK 
Length: unspecified [text/html] 
Saving to: `www.cycustom.com/large/index.html' 

    [ <=>                                                         ] 188,795  504K/s in 0.4s  

Last-modified header missing -- time-stamps turned off. 
2012-01-10 18:19:37 (504 KB/s) - `www.cycustom.com/large/index.html' saved [188795] 

Loading robots.txt; please ignore errors. 
--2012-01-10 18:19:37-- http://www.cycustom.com/robots.txt 
Connecting to www.cycustom.com|64.244.61.237|:80... connected. 
HTTP request sent, awaiting response... 200 OK 
Length: 174 [text/plain] 
Saving to: `www.cycustom.com/robots.txt' 

100%[======================================================================================================================================================================================================================================>] 174   --.-K/s in 0s  

2012-01-10 18:19:37 (36.6 MB/s) - `www.cycustom.com/robots.txt' saved [174/174] 

FINISHED --2012-01-10 18:19:37-- 
Downloaded: 2 files, 185K in 0.4s (505 KB/s) 

はここでファイルの絵がhttps://img.skitch.com/20120111-nputrm7hy83r7bct33midhdp6d.jpg

私の目的は、画像ファイルの完全なフォルダを持つことです作成します。ここでは、コマンドの出力です。次のコマンドはこの目的を達成しませんでした。

wget --mirror --no-parent http://www.cycustom.com/large/ 
+0

@sarnold:たとえば、このオプションは、一つのファイルと次の間で30秒待機します20120111-1uapp8upbq6qmtrwsqsiygg62i.jpg) –

答えて

3
wget --mirror --no-parent http://www.example.com/large/ 

--no-parentは、Webサイト全体をズルズルのを防ぐことができます。


ああ、私は彼らがそのディレクトリからない写真のダウンロードへrobots.txt求めてロボットを配置している参照してください。

$ curl http://www.cycustom.com/robots.txt 
User-agent: * 
Disallow: /admin/ 
Disallow: /css/ 
Disallow: /flash/ 
Disallow: /large/ 
Disallow: /pdfs/ 
Disallow: /scripts/ 
Disallow: /small/ 
Disallow: /stats/ 
Disallow: /temp/ 
$ 

wget(1)robots.txtを無視する任意の方法が記述されていないと私が見つかりましたことはありません--mirrorの同等物をcurl(1)に簡単に実行する方法です。 wget(1)を引き続き使用したい場合は、中間にHTTPプロキシを挿入して、リクエストの場合は404を返す必要があります。

アプローチを変更する方が簡単だと思います。二回URLを埋め込むビット醜いです -

#!/usr/bin/ruby 
require 'open-uri' 
require 'nokogiri' 

doc = Nokogiri::HTML(open("http://www.cycustom.com/large/")) 

doc.css('tr > td > a').each do |link| 
    name = link['href'] 
    next unless name.match(/jpg/) 
    File.open(name, "wb") do |out| 
    out.write(open("http://www.cycustom.com/large/" + name)) 
    end 
end 

これは単なる迅速かつ汚いスクリプトです:私はNokogiriを使用してより多くの経験をしたかったので、ここで私が思いついたものです。したがって、これを長期間の生産に使用する場合は、最初に清掃してください。代わりにrsync(1)の使用方法を理解してください。

+0

オリジナルの質問を編集して、あなたの提案の結果を追加しました –

4

robots.txtファイルには、次のオプションを追加することによって無視することができます。

-e robots=off 

私はまた、サーバーの負荷を制限するために、ダウンロードを遅くするためのオプションを追加することをお勧めします。 (https://img.skitch.com/ [ここではいくつかの注意事項/ wを作成したindex.htmlファイルの絵だ]

--wait 30 
関連する問題