Python에서 wget 명령 사용
Lakshay Kapoor
2023년10월10일
Python
Python Wget

wget
은 백그라운드에서 작동할 수 있는 URL 네트워크 다운로더로, 메인 서버에서 직접 파일을 다운로드할 수 있도록 도와줍니다. Python에서 이 작업은 wget
모듈을 사용하여 수행됩니다.
Python의 wget
모듈
Python의 wget
모듈에서 파일의 최종 대상은 특정 파일을 다운로드하기 위해 백그라운드에서 열 필요가 없습니다. 특정 파일을 다운로드하려면 URL과 파일의 명확한 경로를 언급해야 합니다.
wget
모듈을 다운로드하려면 다음 명령을 실행하십시오.
pip install wget
wget
모듈의 download
메소드는 모든 파일을 한 줄로 다운로드합니다.
wget
모듈의 download
방법을 사용하여 웹사이트에서 파일을 다운로드하는 예를 살펴보겠습니다. www.randomdatabase.com
이라는 웹사이트에서 CSV 파일 형식인 main_database.csv
라는 데이터베이스 파일을 다운로드해야 합니다.
import wget
site_url = "https://sample-videos.com/csv/Sample-Spreadsheet-10-rows.csv"
file_name = wget.download(site_url)
print(file_name)
URL과 파일의 적절한 경로는 별도의 변수에 저장되며 해당 변수는 wget
모듈의 download
메서드 인수입니다.
튜토리얼이 마음에 드시나요? DelftStack을 구독하세요 YouTube에서 저희가 더 많은 고품질 비디오 가이드를 제작할 수 있도록 지원해주세요. 구독하다
작가: Lakshay Kapoor
Lakshay Kapoor is a final year B.Tech Computer Science student at Amity University Noida. He is familiar with programming languages and their real-world applications (Python/R/C++). Deeply interested in the area of Data Sciences and Machine Learning.
LinkedIn