Python 3

๊ธฐ์‚ฌ ์›น์Šคํฌ๋ž˜ํ•‘(ํฌ๋กค๋ง)ํ•ด์„œ ์ด๋ฉ”์ผ ๋ณด๋‚ด๊ธฐ

๊ธฐ์‚ฌ ์›น์Šคํฌ๋ž˜ํ•‘(ํฌ๋กค๋ง)ํ•˜๊ธฐ ํฌ๋กค๋ง ํ•˜๊ณ ์‹ถ์€ ๋ถ€๋ถ„์„ ์šฐํด๋ฆญ > ๊ฒ€์‚ฌ > Copy > Copy selector ์›น์‚ฌ์ดํŠธ ๋งˆ๋‹ค HTML ๊ตฌ์กฐ๊ฐ€ ๋‹ค๋ฅด๊ธฐ๋•Œ๋ฌธ์— ์›ํ•˜๋Š” ์ •๋ณด๋ฅผ ์–ป๋Š” ๋ฐฉ๋ฒ•๋งŒ ์•Œ๋ฉด ๐Ÿ‘Œ from bs4 import BeautifulSoup from selenium import webdriver driver = webdriver.Chrome('chromedriver') url = "https://search.naver.com/search.naver?where=news&sm=tab_jum&query=์ถ”์„" driver.get(url) req = driver.page_source soup = BeautifulSoup(req, 'html.parser') articles = soup.select('#main_p..

Python 2020.10.13

์นด์นด์˜คํ†ก ์›Œ๋“œํด๋ผ์šฐ๋“œ ๋งŒ๋“ค๊ธฐ

์›Œ๋“œํด๋ผ์šฐ๋“œ ํ™˜๊ฒฝ ์„ค์ • ์›Œ๋“œํด๋ผ์šฐ๋“œ ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•œ๋‹ค. File > Settings > Python Interpreter > wordcloud import matplotlib.font_manager as fm # ์ด์šฉ ๊ฐ€๋Šฅํ•œ ํฐํŠธ ์ค‘ '๊ณ ๋”•'๋งŒ ์„ ๋ณ„ -> ๊ธ€์”จ๊ฐ€ ๊ตต์–ด์•ผ ์˜ˆ๋ป์„œ for font in fm.fontManager.ttflist: if 'Gothic' in font.name: print(font.name, font.fname) ์ด ์ฝ”๋“œ๋ฅผ ์‹คํ–‰์‹œํ‚ค๋ฉด ๊ทธ๋Ÿฌ๋ฉด ํฐํŠธ์˜ ๊ฒฝ๋กœ๋“ค์ด ์ญ‰ ์ถœ๋ ฅ๋  ํ…๋ฐ, ๊ทธ์ค‘ ๋งˆ์Œ์— ๋“œ๋Š” ํฐํŠธ ๊ฒฝ๋กœ ํ•˜๋‚˜ ๋ณต์‚ฌํ•ด๋†“๊ธฐ. (BUT ์›Œ๋“œํด๋ผ์šฐ๋“œ๊ฐ€ ์ œ๋Œ€๋กœ ๋งŒ๋“ค์–ด์ง€์ง€ ์•Š๋Š” ํฐํŠธ๋“ค์ด ๋งŽ๊ธฐ ๋•Œ๋ฌธ์— MalgunGothic(์œˆ๋„์šฐ), AppleGothic(๋งฅ)์„ ์ฃผ๋กœ ์‚ฌ์šฉํ•˜์ž!) from wor..

Python 2020.10.13

์ด๋ฏธ์ง€ ์›น ์Šคํฌ๋ž˜ํ•‘(์›น ํฌ๋กค๋ง)ํ•˜๊ธฐ

dload ํŒจํ‚ค์ง€ ์„ค์น˜ dload๋Š” ์ด๋ฏธ์ง€ ๋‹ค์šด๋กœ๋“œ๋ฅผ ์‰ฝ๊ฒŒ ๋„์™€์ฃผ๋Š” ํŒจํ‚ค์ง€์ด๋‹ค. File > Settings > Python Interpreter ์˜ค๋ฅธ์ชฝ์— + ๋ฒ„ํŠผ ๋ˆŒ๋Ÿฌ์„œ dload ๊ฒ€์ƒ‰ import dload dload.save("์ด๋ฏธ์ง€ ์ฃผ์†Œ") ๊ตฌ๊ธ€์—์„œ ์•„๋ฌด ์ด๋ฏธ์ง€๋‚˜ ๊ฒ€์ƒ‰ํ•ด์„œ '์ด๋ฏธ์ง€ ์ฃผ์†Œ ๋ณต์‚ฌ'ํ•ด์„œ ๋งํฌ๋ฅผ ๋„ฃ์–ด์ฃผ๋ฉด ์ด๋ฏธ์ง€๊ฐ€ ์ €์žฅ๋œ๋‹ค. ์…€๋ ˆ๋‹ˆ์›€ ์„ค์น˜ ์…€๋ ˆ๋‹ˆ์›€์€ ๋ธŒ๋ผ์šฐ์ €๋ฅผ ์ž๋™์œผ๋กœ ์ œ์–ดํ•ด์ฃผ๋Š” ํŒจํ‚ค์ง€์ด๋‹ค. File > Settings > Python Interpreter seleninum ๊ฒ€์ƒ‰ > Install Package ์…€๋ ˆ๋‹ˆ์›€ ์›น๋“œ๋ผ์ด๋ฒ„ ์„ค์น˜ ํฌ๋กฌ ๋ธŒ๋ผ์šฐ์ € > ๋„์›€๋ง > Chrome ์ •๋ณด > ํฌ๋กฌ ๋ฒ„์ „ ํ™•์ธ ์…€๋ ˆ๋‹ˆ์›€ ์›น๋“œ๋ผ์ด๋ฒ„ ์„ค์น˜ ๋งํฌ๋กœ ๊ณ ๊ณ  chromedriver.storage.googleap..

Python 2020.10.02