업무를 하다보면 인터넷 정보를 찾을 때 반복적인 행동이 필요할 수가 있다.
이때 파이썬을 통해 자동화를 세팅하여 나의 시간을 아낄 수 있다.
결론적으로 책을 따라서 진행하면 아래와 같이 반도체 관련 인터넷 기사를 워드 클라우드로 정리할 수 있다.
하지만 실습을 하면서 오류가 없었던건 아니다.
실습을 하면서, 생긴 오류와 어떻게 해결했는지 공유하고자 한다.
1. Wordcloud 설치 실패
책에 기입되어 있는대로 기입하니 wordcloud 설치가 되지 않았다.
그래서 아래의 사이트에서 언급한것과 같이 wordcolud 설치를 위해 아래와 같이 수정하니 설치가 되었다.
conda install -c https://conda.anaconda.org/conda-forge wordcloud
https://justjs.tistory.com/117
2. pandas 설치 오류
파이썬 3.12는 pandas 지원이 되지 않는다고 하여,
3.7로 버젼을 변경하니 설치가 되었다.
3. cannot open resource
폰트가 설치가 되어 있지 않아 오류가 발생하였다.
실습자료에 있는 "BMJUA_ttf"자료를 바탕화면에 복사해서 다시 실행하면 정상 작동한다.
[파이썬 上 작성한 내용]
!pip install selenium==4.1.5
import selenium
!pip install selenium webdriver_Manager
from selenium import webdriver
from seleniuhttp://m.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from seleniuhttp://m.webdriver.common.by import By
service = Service(executable_path=ChromeDriverManager().install())
options=webdriver.ChromeOptions()
options.add_argument('--no-sandbox')
driver=webdriver.Chrome(service=service)
driver.get("https://www.naver.com")
greenbox=driver.find_element(By.XPATH, "/html/body/div[2]/div[1]/div/div[3]/div/div/form/fieldset/div/input")
greenbox.send_keys("반도체")
driver.find_element(By.CLASS_NAME, "ico_btn_search_svg").click()
import pandas as pd
df = pd.DataFrame(news_title_lists)
df
df.to_excel('bhyunco_test.xlsx')
!pip install wordcloud
from wordcloud import WordCloud, STOPWORDS
stopwords=set(STOPWORDS)
wc=WordCloud(font_path="BMJUA_ttf.ttf", stopwords=stopwords)
wc.generate(str(news_title_lists))
wc.to_file('wordcloud.png')
※응용편
평소 하남시의 스타월드 진행상황에 대해 궁금하여 자주 검색해 본다.
위에서 배운 것을 토대로 실시하면 아래와 같이 알 수 있었다.
(자세한 내용은 첨부파일 참고하시기 바랍니다.)
'[업무 자동화] > 파이썬' 카테고리의 다른 글
[파이썬] 음원 차트 수집하기(feat. 코드 포함) (2) | 2024.09.22 |
---|---|
[파이썬] 명함 만들기 자동화 (4) | 2024.09.15 |
[파이썬] MS office 자동화 실습(feat. 엑셀, PPT, 워드클라우드) (8) | 2024.09.08 |
[파이썬] 데이터 처리 자동화(feat. pandas, 오류 해결) (0) | 2024.09.01 |
건설업 안전관리자가 파이썬을 공부하는 이유 (0) | 2024.08.11 |