강의

멘토링

커뮤니티

인프런 커뮤니티 질문&답변

김학철님의 프로필 이미지
김학철

작성한 질문수

파이썬 입문 및 웹 크롤링을 활용한 다양한 자동화 어플리케이션 제작하기

파이썬 urllib을 활용한 웹에서 필요한 데이터 추출하기(1)

맥 os에서 실행시 파일저장

작성

·

226

0

맥 os의 아톰에서 하기 문장을 입력 후 실행시,

실행은 되나, 저장된 파일이 안보이네요.

이유가 무엇인지요?

import sys

import io

import urllib.request as dw

sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding = 'utf-8')

sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding = 'utf-8')

imgUrl ="http://post.phinf.naver.net/20160621_169/1466482468068lmSHj_JPEG/If7GeIbOPZuYwI-GI3xU7ENRrlfI.jpg"

htmlURL ="http://google.com"

savePath1 ="/Users/ken/test1.jpg"

savePath2 ="/Users/ken/index.html"

f = dw.urlopen(imgUrl).read()

f2 = dw.urlopen(htmlURL).read()

saveFile1 = open(savePath1,'wb') # w : write , r : read , a : add

saveFile1.write(f)

saveFile1.close()

with open(savePath2,'wb') as saveFile2:

saveFile2.write(f2)

print("다운로드 완료!")

답변

답변을 기다리고 있는 질문이에요
첫번째 답변을 남겨보세요!
김학철님의 프로필 이미지
김학철

작성한 질문수

질문하기