본문 바로가기

Study/Python28

[Python] 주피터 노트북으로 파이썬 시작하기 In[1]: 1+2 Out[1]: 3 Jupyter notebook 사용방법 단축키 In [2]: # 주석사용방법 # 단축키 ctrl + / In [3]: # 변수에 숫자 num1 = 13 print(num1) num2 = 5.8 print(num2) num1 = 10.5 print(num1) 13 5.8 10.5 변수명 단축키 In [4]: # 문자열 대입 str1 = 'Funny Python' str2 = "Easy Python" print(str1) print(str2) num1 = 'Kimmihee' print(num1) Funny Python Easy Python Kimmihee In [5]: int num1 = 10; int num2 = 15; # 치환 temp = num1 num1 = num.. 2023. 9. 29.
[Python] 크롤링 이미지 데이터 수집하기 from selenium import webdriver as wb from selenium.webdriver.common.by import By import time from selenium.webdriver.common.keys import Keys # 파일 시스템을 위한 라이브러리(삭제, 생성) import os # 이미지의 경로를 실제 파일로 저장 from urllib.request import urlretrieve In [1]: # 폴더 생성 # 바탕화면에 이미지라는 폴더가 없다면 바탕화면에 이미지라는 폴더를 만들기 if not os.path.isdir("C:/Users/gjaischool/Desktop/이미지") : os.mkdir("C:/Users/gjaischool/Desktop/이미지") .. 2023. 9. 5.
[Python] 크롤링 네이버 지도 데이터 수집- iframe 전환 In [1]: from selenium import webdriver as wb from selenium.webdriver.common.by import By import time from selenium.webdriver.common.keys import Keys In [2]: # 1. 크롬드라이버를 실행해서 네이버지도 사이트로 이동 driver = wb.Chrome() driver.get("https://map.naver.com/p?c=15.00,0,0,0,dh") In [3]: # 2. 검색창에 검색어를 입력(동명동 회식) # 검색창의 구분자인 id값이 실행할 때마다 변한다 # 이런 경우 다른 선택자를 활용 search = driver.find_element(By.CSS_SELECTOR,".inpu.. 2023. 9. 4.
[Python] 크롤링 (한솥도시락 메뉴 수집해보기) from selenium import webdriver as wb from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys In [1]: # 1. 브라우저를 실행하고 한솥사이트로 이동 driver = wb.Chrome() driver.get("https://www.hsd.co.kr/menu/menu_list") In [2]: # 2. 상품이름 수집 title = driver.find_elements(By.CSS_SELECTOR, ".h.fz_03") for i in title : print(i.text) In [3]: # 3. 상품가격 수집 price = driver.find_elements(By... 2023. 9. 1.