본문 바로가기
  • Tried. Failed. Logged.
728x90

파이썬84

PyQt - 트레이(Tray) 만들기 및 메뉴 추가 from PyQt5.QtGui import QIcon trayIcon = QSystemTrayIcon(Form) icon = QIcon("icon.png") trayIcon.setIcon(icon) trayIcon.setToolTip('트레이 아이콘 설명') trayIcon.setVisible(True) trayIcon.show() menu = QMenu() exitAction = menu.addAction('Exit') exitAction.triggered.connect(app.quit) trayIcon.setContextMenu(menu) 참고: https://www.pythonguis.com/tutorials/system-tray-mac-menu-bar-applications-pyqt/ System.. 2022. 5. 7.
PyQt - designer 스타일시트 추가하기 원하는 위젯 우클릭하고 styleSheet 바꾸기 클릭 ​이런식으로 border, :hover 등 다양한 스타일시트를 설정할 수 있음 문법은 CSS와 동일하며 다만 기능은 더 적다. 참고: https://blog.naver.com/PostView.naver?blogId=dhksrl0508&logNo=222344023916&parentCategoryNo=&categoryNo=232&viewDate=&isShowPopularPosts=false&from=postView PyQt StyleSheet로 Visual Studio UI를 만들어보자 마이크로소프트는 UI를 정말 잘 만드는 것 같습니다. 학교 공부로 Visual C++ 실습을 진행하는데, 우연... blog.naver.com 2022. 5. 7.
셀레니움 - 네이버 로그인 봇 탐지 우회하기 from selenium import webdriver from selenium.webdriver.common.keys import Keys import pyperclip import time uid = '{아이디}' upw = '{비밀번호}' driver = webdriver.Chrome('chromedriver.exe') driver.implicitly_wait(15) driver.get('https://nid.naver.com/nidlogin.login?mode=form&url=https%3A%2F%2Fwww.naver.com') pyperclip.copy(uid) time.sleep(1) driver.find_element_by_xpath('/html/body/div[1]/div[2]/div/di.. 2022. 2. 8.
OpenCV - 파이썬 웹캠 눈, 얼굴 인식 import cv2 face_cascade_filename = 'haarcascade_frontalface_default.xml' face_cascasde = cv2.CascadeClassifier( cv2.data.haarcascades + face_cascade_filename) eye_cascade_filename = 'haarcascade_eye.xml' eye_cascade = cv2.CascadeClassifier( cv2.data.haarcascades + eye_cascade_filename) capture = cv2.VideoCapture(0) while cv2.waitKey(33) < 0: ret, frame = capture.read() faces = face_cascasde.dete.. 2022. 2. 2.
OpenCV - 파이썬 웹캠 얼굴 인식 import cv2 cascade_filename = 'haarcascade_frontalface_default.xml' cascasde = cv2.CascadeClassifier( cv2.data.haarcascades + cascade_filename) capture = cv2.VideoCapture(0) while cv2.waitKey(33) < 0: ret, frame = capture.read() faces = cascasde.detectMultiScale(frame, 1.3, 5) for (x, y, w, h) in faces: cv2.rectangle(frame, (x,y), (x + w, y + h), (255,0,0), 2) cv2.imshow('frame', frame) capture... 2022. 2. 2.
파이썬 - Cloudflare 우회하여 크롤링하기 pip install cloudscraper import cloudscraper scraper = cloudscraper.create_scraper() # returns a CloudScraper instance # Or: scraper = cloudscraper.CloudScraper() # CloudScraper inherits from requests.Session print scraper.get("http://somesite.com").text 나무위키 또한 Cloudflare를 사용하기 때문에 일반적인 방법으로는 크롤링이 힘들다. 근데 이 모듈 설치하면 크롤링이 가능해짐. 출처: https://stackoverflow.com/questions/49087990/python-request-being.. 2022. 1. 29.
셀레니움 - 브라우저 현재 url 가져오기 driver.current_url 2022. 1. 15.
파이썬 - base64를 이미지 파일로 저장하기 import base64 imgdata = base64.b64decode(imgstring) filename = 'some_image.jpg' # I assume you have a way of picking unique filenames with open(filename, 'wb') as f: f.write(imgdata) # f gets closed when you exit the with statement # Now save the value of filename to your database 출처: https://stackoverflow.com/questions/16214190/how-to-convert-base64-string-to-image/16214280 How to convert base6.. 2021. 12. 8.
파이썬 - 여러개의 문자열 변경하기 import re txt = "Hi, my phone number is 089992654231. I am 34 years old. I live in 221B Baker Street. I have 1,000,000 in my bank account." def processString3(txt): txt = re.sub('[0-9]', 'X', txt) print(txt) processString3(txt) 출처: https://www.delftstack.com/ko/howto/python/python-replace-multiple-characters/ Python에서 문자열의 여러 문자를 바꾸는 방법 이 기사는 Python에서 문자열의 여러 문자를 바꾸는 방법을 보여줍니다. www.delftstack.com 2021. 12. 8.
Flask - static 파일들 제공하기 from flask import Flask, request, send_from_directory # set the project root directory as the static folder, you can set others. app = Flask(__name__, static_url_path='') @app.route('/js/') def send_js(path): return send_from_directory('js', path) if __name__ == "__main__": app.run() 출처: https://stackoverflow.com/questions/20646822/how-to-serve-static-files-in-flask How to serve static files in .. 2021. 12. 8.
Scapy - Scapy로 ftp 계정 정보 알아내기 #!/usr/bin/python from scapy.all import* protocols = {1:'ICMP', 6:'TCP', 17:'UDP'} def showPacket(packet): src_ip = packet[0][1].src dst_ip = packet[0][1].dst proto = packet[0][1].proto if proto in protocols: print( "protocol: %s: %s -> %s" %(protocols[proto], src_ip, dst_ip) ) print( "data: ", packet[0][1].payload ) if proto == 1: print( "TYPE: [%d], CODE[%d]" %(packet[0][2].type, packet[0][2]... 2021. 12. 5.
Scapy - Scapy로 지나가는 패킷 확인하기 #!/usr/bin/python from scapy.all import* protocols = {1:'ICMP', 6:'TCP', 17:'UDP'} def showPacket(packet): src_ip = packet[0][1].src dst_ip = packet[0][1].dst proto = packet[0][1].proto if proto in protocols: print( "protocol: %s: %s -> %s" %(protocols[proto], src_ip, dst_ip) ) if proto == 1: print( "TYPE: [%d], CODE[%d]" %(packet[0][2].type, packet[0][2].code) ) def sniffing(filter): sniff(filt.. 2021. 12. 5.
728x90