[JsonCpp] Json 문자열 파싱 int main(){ std::string jsonString = R"({ "PlayerName": "testid", "PlayerHP": 20, "Items": ["Potion1", "Potion2"] })"; Json::Value root; Json::CharReaderBuilder reader; std::string errs; std::istringstream s(jsonString); if (!Json::parseFromStream(reader, s, &root, &errs)) { std::cerr 2025. 3. 22. [JsonCpp] 설치 1. Git에서 소스코드를 Clonegit clone https://github.com/open-source-parsers/jsoncpp.git 2-1. 소스 코드로 추가해서 사용1. Clone 한 경로에서 amalgamate.py 파이썬을 실행(파이썬은 설치되어있어야 한다) 2. dist폴더에 소스 파일들이 생성됨- jsoncpp.cpp- json/json.h- json/json-forwards.h 3. 해당 소스 파일을 사용할 프로젝트에 추가해서 사용- 폴더 구조는 그대로 맞춰줘야 함.(jsoncpp.cpp가 json/json.h 형태로 헤더를 참조) 4. 파일 2025. 3. 22. [Selenium] 스크롤 현재 스크롤 위치를 얻는 함수# 스크롤 위치를 얻는다def GetScrollY(): return driver.execute_script("return window.pageYOffset") 스크롤 높이를 얻는 함수# 스크롤 높이를 얻는다def GetScrollHeight(): return driver.execute_script("return document.body.scrollHeight") 일정 횟수 만큼 스크롤인자로 횟수를 받아 그만큼 스크롤 하고 0이거나 작은값이 들어오는경우는 끝까지 스크롤# 0보다 큰값이 설정된 경우 해당 횟수만큼 스크롤하고 0이거나 작은 값인경우는 끝이 나올때까지 스크롤def ScrollByCount(scroll_count): # 마지막 스크롤 위치 .. 2024. 9. 18. [Selenium] Python에서 대기 방법 1. time.sleep(초)# importfrom time import sleep# 1초 대기sleep(1) 2. driver.implicitly_wait(초)# 2초 대기driver.implicitly_wait(2) 3. WebDriverWait지정한 Element가 로드될때까지 대기from selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions# 드라이버 생성 ...# 구글 이미지의 검색창이 로드 될때까지 대기# 3초 대기하다가 찾지 못한경우 selenium.common.exceptio.. 2024. 9. 18. [Selenium] Element 클릭 처리 1. click() 함수 호출# 클릭할 element를 찾는다target_element = driver.find_element(By.XPATH, xpath)# 클릭 함수 호출target_element.click() 2. 해당 Element에 enter 키 입력# 클릭할 element를 찾는다target_element = driver.find_element(By.XPATH, xpath)# enter 키 입력target_element.send_keys(Keys.ENTER) 3. execute_script 로 입력 처리1, 2 번의 경우 화면상에 보이지 않는 Element의 경우 ElementClickInterceptedException이 발생하지만 execute_script로 클릭 처리하는경우 정상적으로.. 2024. 9. 17. [Selenium] Element Element 회득# 해당 모듈에 find_element에 사용할 키 스트링이 정의되어있음from selenium.webdriver.common.by import By# 드라이버 획득# ...# 클래스 이름으로 Element 획득element1 = driver.find_element(By.CLASS_NAME, "gLFyf")# xpath로 Element 획득element2 = driver.find_element(By.XPATH, "/html/body/div[1]/div[3]/form/div[1]/div[1]/div[4]/center/input[1]") XPath(XML Path Language)는 XML문서 상의 경로를 표현한다 CLASS_NAME이 중복되는 경우 find_element(By.CLASS_.. 2024. 9. 7. [Selenium] WebDriver WebDriver는 웹 브라우저를 컨트롤 하기위한 언어 중립적인 API 및 프로토콜각 브라우저는 driver라고하는 특정 WebDriver구현으로 지원driver는 브라우저의 대리자 역활을 하는 구성요소이고 Selenium과 브라우저간 통신을 처리 8가지 기본 구성요소Selenium이 수행하는 모든 작업은 브라우저에 명령을 보내거나 정보를 요청하는것Selenuim이 수행하는 대부분의 작업은 이러한 기본 명령의 조합임 1. 세션 시작driver = webdriver.Chrome()# URL 열기dirver.get("https://images.google.com/")# 로컬 파일열기dirver.get("file://Users/....") 2. 브라우저에서 작업 수행3. 브라우저에 정보요청 4. 대기 전력 수.. 2024. 8. 31. [Selenium] 기본 https://www.selenium.dev/documentation/ The Selenium Browser Automation ProjectSelenium is an umbrella project for a range of tools and libraries that enable and support the automation of web browsers. It provides extensions to emulate user interaction with browsers, a distribution server for scaling browser allocation, and the infrawww.selenium.dev Selenium이 수행하는 모든 작업은 브라우저에 명령을 보내어 수행하거나 정보 요.. 2024. 8. 30. 이전 1 다음