Skip to Content
Suffering builds character

1.wget,curl, 리소스 요청, 다운로드

지정한 URL로 요청을 전송하여, 리소스를 다운로드할 수 있음

웹 상에서 파일을 다운로드 하기 위해서는 wget나 curl 등으로 받을 수 있으며, 리소스를 제공하는 사이트에 따라 명령어가 다르기 때문에 상황에 맞게 사용

URL 테스트용 사이트인 https://httpbin.org/  를 통해 명령어 테스트

wget 명령어를 통해 https://httpbin.org/  index.html 파일 다운로드

wget https://httpbin.org

현재 경로에 다운로드 여부 조회

ls index.html

index.html 내용 조회

cat index.html

index.html 파일 제거

rm index.html

curl 명령어를 통해 https://httpbin.org/  index.html 파일 다운로드

curl https://httpbin.org/

curl 명령의 기본 옵션은 파일 다운로드가 아닌 콘솔에 출력하기 때문에 명령어의 실행 결과로 파일을 다운받지 않고, 웹 페이지가 출력됨

... <h2>Other Utilities</h2> <ul> <li> <a href="/forms/post">HTML form</a> that posts to /post /forms/post</li> </ul> <br /> <br /> </div> </section> </div> </div> </body>

-O 옵션을 통해 파일 다운로드

curl -O www.google.com/index.html
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--100 19379 0 19379 0 0 98872 0 --:--:-- --:--:-- --:--:-- 98872

다운로드가 진행되고 ls를 통해 파일이 다운로드 된 것을 확인할 수 있음

Last updated on