- 0
- 이니스프리
- 조회 수 1027
다음과 같은 방법으로 Requests에서의 다운로드 진행도를 프로그레스바로 간단히 표시할 수 있어요~!
참고로 requests를 개발하신 분이 clint도 개발하셨다고 알고 있네요 ㅎㄷㄷ
1 2 3 4 5 6 7 8 9 10 11 | import requestsfrom clint.textui import progressr = requests.get(url, stream=True)path = '/path/filename.ext'with open(path, 'wb') as f: total_length = int(r.headers.get('content-length')) for chunk in progress.bar(r.iter_content(chunk_size=1024), expected_size=(total_length/1024) + 1): if chunk: f.write(chunk) f.flush() |
작성자
댓글 0
권한이 없습니다.



