일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- 네이버커머스API
- pywinauto 윈도우
- 네이버부동산크롤링
- 파이썬 네이버 로그인
- pywinauto 윈도우제어
- Uipath 기초
- 날짜 정규식
- pywinauto
- 가상환경설치
- selenium
- 파이썬 환경설정
- 파이썬네이버부동산
- pycdc.exe
- uipath 입문
- 커머스API
- 네이버 로그인 영수증 해결
- 네이버매물크롤링
- Uipath 설치방법
- 네이버 로그인 하기
- vscode venv 설치
- 네이버 로그인 캡챠해결
- Selenium 셀렉터잡기
- Python
- 파이썬 가상환경 설치방법
- 파이썬 가상환경 설치
- Element is not clickable at point
- venv 설치
- pycdas.exe
- 왕초보 파이썬 실행
- UiPath
- Today
- Total
목록프로그래밍/python (267)
콘솔워크
pip install python-docx from docx import Document # 새로운 Document 객체 생성 doc = Document() # 저장할 문자열 my_text = "Hello, world!" # 문자열을 문서에 추가 doc.add_paragraph(my_text) # 문서 저장 doc.save('my_document.docx')
my_str = '10' print(my_str.isdigit()) my_str = '10ㅁㄴㅇㄹ' print(my_str.isdigit()) True False 형태로 출력된다.
[준비물] 일단 ADB설정부터 마치고 와야함 https://uipath.tistory.com/279 [adb] android의 크롬을 개발자 도구(F12)로 확인해보기 아래의 글을 참고하여 adb device 설정까지 마쳐야 함 https://uipath.tistory.com/230 [adb] python 안드로이드 스마트폰 제어하기 1. 스마트폰과 연결하기 위해 구글 개발자 페이지에서 adb (android device bridge)를 uipath.tistory.com appium 클라이언트도 깔아야 함 https://appium.io/ Appium: Mobile App Automation Made Awesome. Appium Philosophy Appium is built on the idea tha..
my_list = ['a', 'b', 'c'] my_string = 'abcde' if any(s in my_string for s in my_list): print("포함") else: print("포함되어있지 않음") my_list = ['a', 'b', 'c'] my_string = 'ㄱㄴㄷㄻ' if any(s in my_string for s in my_list): print("포함") else: print("포함되어있지 않음") any() 함수를 활용해서 구분이 가능하다!!
driver.switch_to.parent_frame() driver.switch_to.default_content() 간혹 옥션 중고장터와 같이 여러개의 iframe으로 구성된 사이트가 있는데, 이러한 경우 유용하게 사용할 수 있다.
import datetime today = datetime.now() trial = datetime(2023, 2, 21) print(f"today: {today}, trail: {trial}") if today
아래의 글을 참고하여 adb device 설정까지 마쳐야 함 https://uipath.tistory.com/230 [adb] python 안드로이드 스마트폰 제어하기 1. 스마트폰과 연결하기 위해 구글 개발자 페이지에서 adb (android device bridge)를 설치합니다. https://developer.android.com/studio/releases/platform-tools?hl=ko#downloads SDK 플랫폼 도구 출시 노트 | Android 개발자 | An uipath.tistory.com 디바이스 확인이 완료되었으면 핵심만 요약 1. cmd 창에서 아래의 명령어 입력 adb shell am start -a android.intent.action.VIEW http://www.g..
for i, commonDto in enumerate(common_dto_list): print(f"{i}회차 작업") if i % 300 == 0: print(f'300회마다 해당 코드 실행') enumerate와 나머지값을 계산하는 % 를 활용
num: int = 10 name: str = '이름입니다.' driver: webdriver.Chrome = webdriver.Chrome("chromedriver.exe") 위와 같이 타입을 지정하는 코딩이 가능하다. 해당 변수들을 파라미터끼리 넘겨받다보면 vs code에서 타입을 구분하지 못하여 사용할 수 있는 메소드가 출력되지 않는데 위와 같이 타입을 지정해주면 사용 가능한 기능들이 정상적으로 출력된다. 예를 들면....
import json def get_page_json(self): driver = self.driver search_result = "" search_result = driver.find_element(By.CSS_SELECTOR, "body").get_attribute("textContent") search_result = json.loads(search_result) # print(search_result) return search_result dict 형태의 문자열을 변경
list = [2, 9, 3] list.insert(0, 'a') print(list) # ['a', 2, 9, 3]
file_path = '경로' if os.path.isfile(file_path): os.remove(file_path)
import re title = ' 입니다**' filename = re.sub('[\/:*?"|]','',title)+'.xls' print(filename) #제목 입니다.xls 특수문자를 제거합니다...
import os from enum import Enum from datetime import datetime import json from mimetypes import MimeTypes COMPANY_NAME = "회사이름" PROGRAM_ID = "프로그램이름" APP_DATA_PATH = os.path.join(os.getenv("APPDATA"), COMPANY_NAME) PROGRAM_PATH = os.path.join(APP_DATA_PATH, PROGRAM_ID) if os.path.isdir(APP_DATA_PATH) == False: os.mkdir(APP_DATA_PATH) if os.path.isdir(PROGRAM_PATH) == False: os.mkdir(PROGRAM_PATH..
sample_str = '123,456,789,' sample_str = ";".join(sample_str.rsplit(",", 1)) print(sample_str) 사실 replace가 아닌 join을 활용해서 해결함.
sample_list = [ "1", "2", "3", ] sample_str = ",".join(sample_list) print(sample_str) # 1,2,3 따옴표 안에 구분자를 설정할 수 있다. 위와 같은 경우에는 콤마를 구분자로 이어짐. 따옴표를 비우면 결과값이 123이 된다.
num_list = [1, 1, 3, 3, 5, 5, 7] num_list = list(dict.fromkeys(num_list)) print(num_list)
str = "Hello world, python" if "world" in str: print("Found world") else: print("Not found world") if "java" in str: print("Found java") else: print("Not found java") list를 비교할 때 사용하던 in을 이용해서 문자열도 간편하게 비교가 가능하다.
# 오늘 날짜 today = datetime.now() # 오늘 날짜에 3일 더하기 add_date = today + timedelta(days=3) # 해당 날짜를 원하는 형태로 형변환 ("2023. 01. 25") add_date = add_date.strftime(f"%Y. %m. %d")
content = '본문입니다.' pyperclip.copy(content) # 본문 span 클릭 content_span = driver.find_element(By.CSS_SELECTOR, 'div[data-a11y-title="본문"] p span') # 클립보드 붙여넣기 action = ActionChains(driver) ( action.move_to_element(content_span) .pause(1) .click() .key_down(Keys.CONTROL) .pause(1) .send_keys("v") .key_up(Keys.CONTROL) .pause(1) .perform() ) action.reset_actions() str을 클립보드에 복사한 후 webelement를 클릭하고 붙여..
self.scheduler = BackgroundScheduler(timezone="Asia/Seoul") self.scheduler.start() # 오늘 날짜 year = datetime.today().year month = datetime.today().month day = datetime.today().day print(f"{year} {month} {day}") # 오늘 날짜로 예약 설정 self.scheduler.add_job( self.search_start_button_clicked, "date", run_date=f"{year}-{month}-{day} {hh-mm-ss}" ) # 현재 스케쥴러 비우기 self.scheduler.shutdown() # 현재 스케쥴러의 상태 print(f"..
python의 globals() 함수를 활용하여 변수명을 선언한다. account_list = [ {"아이디": "1111", "비밀번호": "1111"}, {"아이디": "2222", "비밀번호": "2222"}, {"아이디": "3333", "비밀번호": "3333"}, ] for i, account in enumerate(account_list): print(f"{i} / {account}") id = account["아이디"] pw = account["비밀번호"] # 반복문 안에서 변수의 이름을 선언하는 globals() 함수 globals()[f"df_{i}"] = f"{id},{pw}" print(globals()[f"df_{0}"]) print(globals()[f"df_{1}"]) prin..
if 1 == 1: import sys import os sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__)))) import os import pandas as pd class OrderFile: def __init__(self, filepath): self.filepath = filepath self.initData() def get_excel_data_type(self): return { "열1": str, "열2": str, "열3": str, } def initData(self): self.filepath = os.path.normpath(self.filepath) self.filename = os.path.base..
비동기처리?? 작업을 동기적으로 처리한다면 이전 작업이 끝날때까지 다음 작업을 하지 않는다. (Synchronous) 하지만 비동기적으로 처리한다면 흐름이 끊기지 않고 여러 작업의 처리가 가능하다. (Asynchronous) 기존에 네이버 커머스 API를 사용하기 위해 토큰에 접근하는 코드가 하나 있었다. def initData(self): self.set_client_secret_sign() self.set_token() def set_client_secret_sign(self): self.timestamp = round(time.time() * 1000) # 밑줄로 연결하여 password 생성 password = self.client_id + "_" + str(self.timestamp) # bcr..
in_p_tag = re.search("", detailContent, re.I | re.S)
with open(file_path, 'w', encoding='utf-8') as file: json.dump(data, file, indent="\t") json.dump()를 사용할 때 indent 옵션에 \t 을 추가해주면 들여쓰기를 인식하게 된다.
if os.path.isfile(file) == False: f = open(file, "w", encoding="UTF8") else: f = open(file, "r", encoding="UTF8") save_list = f.read().splitlines() f.close() 메모장에서 \n 을 기준으로 한 줄씩 나뉘어진 문장들을 배열에 담을 수 있다.
def remove_special_cha(content: str): new_str = re.sub(r"[^\uAC00-\uD7A30-9a-zA-Z\s,.!?;]", "", content) print(new_str) return new_str 일부 자주 사용하는 특수문자 (,./!?;) 와 띄어쓰기 (\s)를 하나씩 추가해줬다.
https://rapidapi.com/smodin/api/rewriter-paraphraser-text-changer-multi-language Smodin - Text Rewriter, Paraphraser, & Spinner API | RapidAPI Our rewriter changes the syntax, structure, word/phrase order, and uses synonyms when relevant. This rewriter works in in all major languages (english, german, spanish, french, arabic, Chinese, and many more). Max character count of 10,000. Questions? See..
https://newspaper.readthedocs.io/en/latest/ Newspaper3k: Article scraping & curation — newspaper 0.0.2 documentation Newspaper3k: Article scraping & curation Inspired by requests for its simplicity and powered by lxml for its speed: “Newspaper is an amazing python library for extracting & curating articles.” – tweeted by Kenneth Reitz, Author of requests “Newspap newspaper.readthedocs.io 라이브러리 설..