wgetã¨curlã®æ ¹æ¬çãªéã
UNIXã®ä»£è¡¨çãªãã¦ã³ãã¼ãã«wgetã¨curlãããã¾ãã
ããã¦ãã®å ´åã©ããªOSã§ããã©ã¡ããã®ã½ãããã¤ã³ã¹ãã¼ã«ããã¦ããã®ã§ã¯ãªããã¨æãã¾ãã
ãããããã®2ã¤ã®ãã¦ã³ãã¼ãã®æ©è½ã¯ãä¸è¦ä¼¼ã¦ããããã«ãè¦ãã¾ãããå®ã¯ããããã«ç¹å¾´ãè¦ãããã®ã§ãä»æ¥ã¯ããã«ã¤ãã¦è§£èª¬ãã¦ã¿ã¾ãã
wgetã®ç¹å¾´
wgetã®ã¹ãã«ã¯ãçæã§ãã³ãã³ãã§ãããã¨ãããã¨ããã£ã¦ãå¤ãã®äººããæ°ã«å
¥ããã¦ãã¾ãã
ãããªwgetã®ç¹å¾´ã¨ãã¦ãæãéç«ã£ã¦ããã®ããã¯ãã¼ã©ã¨ãã¦åä½å¯è½ã¨ããç¹ã§ãã
ãªãã·ã§ã³ã§-rãä»å ãã¦ãããã¨ã§å帰çã«åä½ãã-lã§ãã®æ·±ããæå®ãããã¨ãã§ãã¾ãã
ã¾ãã-Aã-Rãå©ç¨ããã°ããã¦ã³ãã¼ãããæ¡å¼µåã®ãã¯ã¤ããªã¹ãã¨ãã©ãã¯ãªã¹ããæå®ãããã¨ãå¯è½ã§ãã
ã¤ã¾ããç¹å®ã®ãµã¤ãå
ã«æ£ãã°ã£ã¦åå¨ãããã¡ã¤ã«ããæ¡å¼µåã«ãã£ã¦æå®ãã¦ã³ãã¼ãã§ããã®ã§ãã
curlã«ã¯ãhtmlã«è¨è¿°ããã¦ãããªã³ã¯ããã©ã£ã¦ããæ©è½ã¯ãªãã®ã§ããããªãã¨ã¯ã§ãã¾ããã
ã¾ããèªåã®ãµã¤ãã®ãã¡ã¤ã«ããã¦ã³ãã¼ããã¦ãã©ã¼ãªã³ã°ãè¡ããã¨ããå ´åã«ãããã¯ãwgetã«è»é
ãä¸ããã¾ãã
# -r:å帰çã« -A:æ¡å¼µåãæå® -l:ãªã³ã¯ã®é層ãæå® wget -r -A jpg,png,gif,bmp -l 3 http://www.abc.com/ # -m:ãã©ã¼ãªã³ã° wget -m http://www.abc.com/ # --spideer:å帰çã«ã¯ãã¼ãªã³ã°ããããã©ããã¦ã³ãã¼ãã¯ããªã wget --spider http://www.abc.com/
curlã®ç¹å¾´
curlã®ç¹å¾´ã¯ã対å¿ãã¦ãããããã³ã«ããæ©è½ã®éã«ããã¾ãã
HTTPãHTTPSãFTPãFTPSãSCPãSFTPãTFTPãDICTãTELNETãLDAPãFILEã¨ãå¤ãã®æ¡å¼µåã«å¯¾å¿ãã¦ããä¸ããããã·ãã¦ã¼ã¶ã¼èªè¨¼ãFTPã¢ãããã¼ããHTTP POSTãSSLæ¥ç¶ãªã©ãã§ãã¦ãã¾ãåªããã®ã§ãã
ããã¦ããã®ä¸ããã1ã¤ã®åªããæ©è½ãããã¾ãã
curlã«ã¯é£çªãã¡ã¤ã«ã®ãã¦ã³ãã¼ããå¯è½ã§ãã
wgetã§ããããããã¨ãã¦ããèªåã§ããã¹ããã¡ã¤ã«ã«URLã®ãªã¹ããä½ã£ã¦ã-iãªãã·ã§ã³ã§å
¥åããããããã¾ããã
ãã®ç¹ãcurlã¯å§ãããé£çªãã¡ã¤ã«ã®ãã¦ã³ãã¼ããã§ããããã«ãªã£ã¦ããã®ã§ããããããã®ãã¦ã³ãã¼ãã«éå®ãã¾ãã
# 1ã100ã¾ã§ã®ãã¡ã¤ã« curl -O http://www.abc.com/file_[1-100].jpg # aãzã¾ã§ã®ãã¡ã¤ã« curl -O http://www.abc.com/file_[a-z].jpg # 1ã100ã¾ã§ã10ããã¿ã§ curl -O http://www.abc.com/file_[1-100:10].jpg # one,two,threeã§ç½®ãæã㦠curl -O http://www.abc.com/file_{one,two,three}.jpg
ã¾ã¨ã
ããããã®ç¹å¾´ãã¾ã¨ãã¾ãã¨ãwgetã¯ã¯ãã¼ã©ã¨ãã¦ãcurlã¯é£çªãã¡ã¤ã«ã®ãã¦ã³ãã¼ãã¨ãã¦ã®æ©è½ãçãè¾¼ã¾ãã¦ãã¾ãã
両æ¹ã¨ãåªããæ©è½ãæã£ã¦ããã®ã§ãç¶æ³ã«ãã£ã¦ä½¿ãåãã§ãããæé«ã§ããã