[Python] 문자열 제거 1. 공백 제거 test= " Hello World " print("lstrip :[" + test.lstrip()+"]") print("rstrip :[" + test.rstrip()+"]") print("strip :[" + test.strip()="]") # lstrip :[Hello World ] # rstrip :[ Hello World] # strip :[Hello World] 2. 특정 문자 제거 test= www.test.com.www print("lstrip :[" + test.lstrip('w')+"]") print("rstrip :[" + test.rstrip('w')+"]") print("strip :[" + test.strip('w')="]") # lstrip :[.test.com.. selenium/문자열 2022. 9. 17. 14:28
[Python] 문자열 줄바꿈 기준으로 자르기 (splitline) Hello World Bye 라는 문장이 있을 경우 print("splitline1 : "+text.splitline()[0]) print("splitline2 : "+text.splitline()[1]) print("splitline3 : "+text.splitline()[2]) # splitline1 : Hello # splitline2 : World # splitline3 : Bye 마지막 리스트 사용을 원할 경우 print("last splitline : "+text.splitline()[-1]) # last split : Bye selenium/문자열 2022. 9. 16. 21:32
[Python] 문자열 자르기 (split) 1. 띄어쓰기 기준으로 문자열 자르기 test_string="Hello World!" test_string.split() 띄어쓰기 기준으로 잘라서 리스트화 시킴 print("split1 : "+test_string.split()[0]) print("split2 : "+test_string.split()[1]) # split1 : Hello # split2 : World 2. 특정 문자로 자름 url = https://monkeycow.tistory.com/ url.split('.') 이면 .을 기준으로 문자열을 잘라서 리스트화 시킴 # url = https://monkeycow.tistory.com/ print("split1 : " + url.split('.')[0]) print("split2 : " +.. selenium/문자열 2022. 9. 16. 21:19
[ERROR] stale element reference: element is not attached to the page document 원인 - 웹페이지가 불러와지기 전에 html을 긁으려고 해서 발생하는 문제 해결방안 - driver.implicitly_wait(3)로는 해결이 안되서 찾아보니 time.sleep(3)으로 걸어주어야 한다고 함 차이 - implicity_wait : 그대로 브라우저에서 사용되는 엔진 자체에서 파싱되는 시간을 기다려 주는 메소드 (모두 로딩되기 전에 엘리먼트를 찾게되면 엘리먼트를 찾을 수 없다는 error 발생) - time.sleep : 무조건 입력한 초 만큼 기다림 selenium 2021. 11. 3. 19:56
[Selenium] CSV 파일 key, value 값으로 읽기 CSV 파일을 읽어서 key, value 값으로 받을 수 있음 import csv def csvfile(): with open('./auto.csv','r') as f: reader = csv.DictReader(f) for row in reader: for key, val in row.items(): print(key,val) selenium 2020. 5. 15. 20:37
[Selenium] 페이지의 Element 갯수 확인 현재 페이지의 Element의 갯수를 확인하고자 할 때 사용 findElements().size() EX) driver.findElements(By.cssSelector("input[type='checkbox']")).size() 현재 페이지의 모든 체크박스 갯수를 확인 selenium 2020. 5. 13. 20:32