Skip to content

Instantly share code, notes, and snippets.

View hunman23's full-sized avatar

sunghun hwang hunman23

View GitHub Profile
@hunman23
hunman23 / gist:1bba5d63da384ecce94fdc12866f1e4e
Last active June 26, 2017 02:58
win32com_excel_handling
import win32com.client
excel = win32com.client.Dispatch('Excel.Application')
excel_file = excel.Workbooks.Open(r'C:\Users\한세영\Desktop\황성훈_엑셀파일\111.xlsx')
work_sheet = excel_file.ActiveSheet
work_sheet.Cells(3,4).select # cell select
work_sheet.paste # paste
excel.visible = True
# Activesheet 변경방법
# work_sheet = excel_file.sheets(1)
from selenium import webdriver
import time
from bs4 import BeautifulSoup
driver = webdriver.Chrome(r'C:\Users\한세영\Downloads\chromedriver_win32\chromedriver.exe')
driver.get('http://www.naver.com')
time.sleep(5)
driver.find_element_by_id('id').send_keys('hunman23')
driver.find_element_by_id('pw').send_keys('tjdgnse1')
time.sleep(5)
driver.find_element_by_xpath('''//*[@id="frmNIDLogin"]/fieldset/span/input''').click()
#Pywin32 설치필요함 link : https://sourceforge.net/projects/pywin32/files/pywin32/
import win32api,win32con,time
time.sleep(2)
# Windows상의 x좌표
x = 50
# Windows상의 y좌표
y = 250
win32api.SetCursorPos((x,y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
import requests
from bs4 import BeautifulSoup
response = requests.get(r'http://www.kma.go.kr/weather/forecast/timeseries.jsp')
response_text = BeautifulSoup(response.text,'html.parser')
for x in response_text.find_all('img'):
print(x['alt'])