[Python/웹 크롤링] 흑백 사진으로 저장하기
흑백 사진으로 저장하기 📌 흑백 사진으로 저장하기 import requests from PIL import Image res = requests.get("https://cdn.mhns.co.kr/news/photo/202102/427143_563231_2949.jpg") f = open("사진.png", "wb") f.write(res.content) img = Image.open("사진.png") w, h = img.size for x in range(0, w): for y in range(0, h): r, g, b = img.getpixel((x, y)) s = (r + g + b) // 3 img.putpixel((x, y), (s, s, s)) img.save(f"사진_흑백.png")
2022. 10. 5.
[Python/웹 크롤링] '독립일기' 웹툰 화 별로 제목, 별점, 참여자수, 등록일 엑셀로 저장하기
'독립일기' 웹툰 화 별로 제목, 별점, 참여자수, 등록일 엑셀로 저장하기 📌 '독립일기' 웹툰 화 별로 제목, 별점, 참여자수, 등록일 엑셀로 저장하기 import requests from bs4 import BeautifulSoup from tqdm import tqdm f = open("독립일기.csv", "w") f.write("제목,별점,참여자수,등록일\n") for i in tqdm(range(1, 205)): res = requests.get(f"https://comic.naver.com/webtoon/detail?titleId=748105&no={i}&weekday=thu") soup = BeautifulSoup(res.text, "html.parser") title = soup.selec..
2022. 10. 5.