하고재비
[python] 이미지 크롤링 + 경로 저장 본문
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | from urllib.request import urlopen import urllib.request from bs4 import BeautifulSoup html = urlopen('######################') soup = BeautifulSoup(html, 'lxml') # 996 - 1002 pic_main = [] for x in range(996, 1003): pic_main_list = soup.find('img', {'id': 'eListPrdImage' + str(x) + '_1'}).get('src') pic_main.append(pic_main_list) f = open("#################", 'w') for i in range(0,len(pic_main)): outpath = "C:/test/" outfile = "testaabb"+str(i)+".png" urllib.request.urlretrieve("http:"+pic_main[i],outpath+outfile) f.write(pic_main[i]) f.write("\n") f.close() | cs |
'Python' 카테고리의 다른 글
[PYTHON] 웹크롤러 (0) | 2017.12.15 |
---|---|
[PYTHON] 크롤링 (0) | 2017.12.08 |
[python] list 선언 (0) | 2017.12.01 |
[python] 디렉토리에 특정파일 찾기 (0) | 2017.12.01 |
[python]꺽은선 그래프 (0) | 2017.12.01 |
Comments