BackEnd/Automation Program with Python
2023.01.18
기상청 xml 데이터 지역별 시간대별 최고 최저 온도 수집 import sys import io import urllib.request as req from bs4 import BeautifulSoup import os.path # 다운로드 url url = 'https://www.kma.go.kr/weather/forecast/mid-term-rss3.jsp?stnId=108' savename = 'C:/forecast.xml' if not os.path.exists(savename): req.urlretrieve(url, savename) # Beautifulsoup 파싱 xml = open(savename, 'r', encoding="utf-8").read() soup = BeautifulSoup(..
BackEnd/Automation Program with Python
2023.01.18
import pickle #(객체, 텍스트) 직렬화, 역직렬화 # 파일이름과 데이터 bfilename = 'C:/test.bin' tfilename = 'C:/test.txt' data1 = 77 data2 = 'hello world' data3 = ['car', 'apple', 'house'] # 바이너리 쓰기 with open(bfilename, 'wb') as f: pickle.dump(data1,f) #dumps(문자열 직렬화) pickle.dump(data2,f) pickle.dump(data3,f) # 텍스트 쓰기 with open(tfilename, 'wt') as f: f.write(str(data1)) f.write('\n') f.write(data2) f.write('\n') f.wri..
BackEnd/Automation Program with Python
2023.01.17
import sys import io from selenium import webdriver from selenium.webdriver.chrome.options import Options import time from selenium.webdriver.common.by import By chrome_options = Options() driver = webdriver.Chrome('webdriver/chrome') #CLI 사용x # driver = webdriver.Chrome(chrome_options=chrome_options,executable_path='webdriver/chrome') driver.implicitly_wait(3) # 암묵적 5초 대기 driver.get('https://ww..
BackEnd/Automation Program with Python
2023.01.17
import sys import io from bs4 import BeautifulSoup import requests sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding = 'utf-8') sys.stddrr = io.TextIOWrapper(sys.stdout.detach(), encoding = 'utf-8') # 로그인 유저정보 LOGIN_info = { 'user_id' : 'test_id_1234', 'user_pw' : 'test_pw_1234!' } # Session 생성 with 구문 안에서 유지 with requests.Session() as s: login_req = s.post('https://user.ruliweb.com/me..