>⛹️♀️ 제로베이스 데이터취업스쿨 15기 스터디노트 23(6.5.)
🗂️ 오늘(6.5.) 수강한 분량
웹데이터 5~6, 유가분석 1~2
🗂️ 웹데이터 5~6, 유가분석 1~2 핵심 내용 정리
folium을 이용한 지도 시각화
- 기존 데이터 불러오기 → gmaps_key 사용 → 해당 위치 좌표 찾기 및 입력 → 마커 및 내용 확인, 저장
gmaps = googlemaps.Client(key=gmaps_key) #google AIP 사용 lat = [] lng = [] for idx, row in tqdm(df.iterrows()): #위치 좌표 넣기 if not row.get("Address") == "Multiple location": target_name = row.get("Address")+ ", " + "Chicago" gmaps_output = gmaps.geocode(target_name) location_output = gmaps_output[0].get("geometry") lat.append(location_output["location"]["lat"]) lng.append(location_output["location"]["lng"]) else: lat.append(np.nan) lng.append(np.nan)
- 네이버 영화 평점사이트 분석
- 크롬 개발자 도구 안에서 영화 제목 찾기 →
find_all
로 접근
- 영화 제목:
td class="title"
안에div class = "tit5"
의<a>
- 영화 평점:
<td class="point">
- 날짜형 데이터 :
date[0]
으로 표기(date[0].strftime("%Y-%m=%f")
등 다양한 형태로 출력 가능- 문자형(string)데이터 중 format 기능
- 영화 평점 데이터 시각화
plt.figure(figsize=(20, 8)) plt.plot(tmp["date"], tmp["point"]) # 선 그래프 x축 날짜, y축 평점 > 시게열 데이터로 표현 plt.title("날짜별 평점") plt.xlabel("날짜") plt.ylabel("평점") plt.xticks(rotation="vertical") plt.legend(labels=["평점 추이"], loc="best") plt.grid(True) plt.show()
- 유가분석 1~2
- selenium Basic
from selenium import webdriver driver = webdriver.Chrome("../driver/chromedriver.exe") #경로를 옵션(크롬)으로 넣음 driver.get("https:/pinkwink.kr") #크롬드라이버에서 웹페이지를 크롬 브라우져로 띄움 dirver.quit() = driver.close() #끔
- selenum 기본 동작(함수)
구분 설명 driver.maximize_window() 화면 최대 크기 설정 driver.minimize_window() 화면 최소 크기 설정 driver.set_window_size(600, 600) 화면 크기 설정 driver.refresh() 새로고침 driver.back() 뒤로가기 driver.forward() 앞으로가기 driver.execute_script('window.open("http://~")') 새 탭 생성 driver.switch_to.window(driver.window_handles[0]) 탭 이동 from selenium.webdriver.common.by import By frist_content = driver.find_element(By.CSS_SELECTOR, '#content > div.cover-masonry > div > ul > li:nth-child(1)') frist_content.click() #클릭하기
- 화면 스크롤
driver.execute_script('return document.body.scrollHeight') #스크롤 가능한 높이(길이)/ 자바스크립트 코드 실행 driver.execute_script('window.scrollTo(0, document.body.scrollHeight);') #화면 스크롤 하단 이동 driver.save_screenshot('./last_heigh.png') #스크린샷 driver.execute_script('window.scrollTo(0, 0);') #화면 스크롤 상단 이동 from selenium.webdriver import ActionChains some_tag = driver.find_element( BY.CSS_SELECTOT('#content > div.cover-masonry > div > ul > li:nth-child(1)')) action = ActionChains(driver) action.move_to_element(some_tag).performs() #특정 태그 지점까지 스크롤 이동
👩🚀 스터디 감정 노트
네이버 영화는 실습을 못해서 약간 음 이게 뭐지 음 어떻게 나오지 하는 상태(근데 늘 그래서 할말 없음ㅠㅠ 빨리 익숙해지자)
[이미지 출처 : 미리캔버스]