공부/Python
-
파이썬 re 모듈공부/Python 2021. 1. 2. 17:20
regax : re 모듈 - 메타문자 : 파이썬에서 특수한 기능을 하는 문자 . ^ $ * + ? \ | ( ) { } [ ] - re 모듈의 함수 match(pattern, string, flag) 문자열의 처음부터 시작해, 작성한 패턴이 일치하는지 확인한다. search(pattern, string, flag) 위의 match와 비슷, 하지만 처음부터 일치하지 않아도 된다. findall(pattern, string, flag) 패턴에 해당하는 케이스를 모두 찾아 리스트로 반환한다. finditer(pattern, string, flag) 위의 findall과 비슷, 하지만 리스트가 아닌 match object로 반환한다. fullmatch(pattern, string, flag) 문자열이 정확히 일..
-
XPath공부/Python 2020. 5. 21. 21:32
마크업 언어에서 특정 요소를 찾기 위한 경로를 나타내는 언어 보통은 ID나 클래스이름으로 특정 요소를 찾는데, 이를 XPath를 사용해 쉽게 찾을 수 있다. 기본 구문 //태그 이름[@속성 '값'] 절대 경로 /html/body/div[2]/div/form/div 상대 경로 //div[@class='form-group'] ex) driver.find_element_by_xpath('//*[@id="frmNIDLogin"]/fieldset/input').click() https://qssdev.tistory.com/42
-
네이버 자동 로그인(selenium)공부/Python 2020. 5. 21. 21:11
selenium모듈을 활용한 자동 네이버 로그인 * chromedriver.exe 와 selenium 모듈을 따로 설치하였다. from selenium import webdriver driver = webdriver.Chrome("C:\\Users\\user\\Desktop\\chromedriver.exe") driver.get("https://nid.naver.com/nidlogin.login") delay = 1 driver.implicitly_wait(delay) #리소스를 기다리는 시간 driver.find_element_by_name('id').send_keys('id') driver.find_element_by_name('pw').send_keys('*******') driver.find_el..
-
python 가변인자공부/Python 2020. 5. 19. 16:08
def 함수이름(*인자이름): 을 통해 파이썬에서 가변인자를 사용할 수 있다. 다음은 여러 수를 입력 받아서 가장 그 중 가장 큰 수를 반환하는 함수를 포함한 프로그램이다. python 3.x 버전 def func(*args): item=list(map(int, args[0])) n = len(item) max = item[0] for i in range(1,n): if max < item[i]: max = item[i] print(max) return max max = func(map(int,input("입력 : ").split())) print("max_num : %d" %max)
-
Request모듈공부/Python 2020. 2. 22. 08:30
Python request 모듈 import requests url = 'https://doraeul19.tistory.com' response = requests.get(url) response.text response.status_code 값 전달 : params = {'파라미터1': '값1', '파라미터2': '값2'} GET : requests.get(url, params=params) POST : request.post(url, cookies="쿠키값", data=params) 예시 더보기 ex ) import requests cookie = {'PHPSESSID':"쿠기값"} url="http://url.php" signup="http://signup.php" old_username="" us..