๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • Tried. Failed. Logged.
728x90

๐Ÿ‘จ๐Ÿผ‍๐Ÿ’ป๊ฐœ๋ฐœ158

ํŒŒ์ด์ฌ - ๋ฆฌ๋ˆ…์Šค์—์„œ GPT ๋ช…๋ น์–ด ์‚ฌ์šฉํ•˜๊ธฐ ๋ชจ๋“ˆ ์„ค์น˜ pip install openai ~/dev/gpt.py import openai import sys openai.api_key = "์ž์‹ ์˜ API ํ† ํฐ์„ ์—ฌ๊ธฐ์— ์ž…๋ ฅ" messages = [ {"role": "system", "content": "You are a helpful assistant."}, ] def request(text:str): global messages if len(messages) >= 30: messages = messages[-10:] query = text messages.append({"role": "user", "content": query}) response = openai.ChatCompletion.create( model="gpt-3.5-turbo", m.. 2023. 5. 22.
์…€๋ ˆ๋‹ˆ์›€ - xpath, ํ…์ŠคํŠธ๊ฐ€ ํฌํ•จ๋œ ์š”์†Œ ์„ ํƒ(contains text) ์›ํ•˜๋Š” ๋ฌธ์ž์—ด์ธ ์š”์†Œ ์ฐพ๊ธฐ ex) ์š”์†Œ์˜ ๋‚ด์šฉ์ด foo์ธ ๊ฒƒ์„ ์ฐพ๊ธฐ //myparent/mychild[text() = 'foo'] ์›ํ•˜๋Š” ๋ฌธ์ž์—ด์ด ํฌํ•จํ•œ(contains) ์š”์†Œ ์ฐพ๊ธฐ ex) ABC๋ผ๋Š” ๋‚ด์šฉ์„ ํฌํ•จํ•œ ์žˆ๋Š” ์š”์†Œ ์ฐพ๊ธฐ //*[contains(text(),'ABC')] ํŒŒ์ด์ฌ ์‚ฌ์šฉ ์˜ˆ์‹œ driver.find_element_by_xpath('//span[contains(text(),"ABC")]') ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ(๋ธŒ๋ผ์šฐ์ € ๊ฐœ๋ฐœ์ž ๋„๊ตฌ) ์‚ฌ์šฉ ์˜ˆ์‹œ $x("//*[contains(text(),'12:00')]") ๊ทธ ๋ฌธ์ž์ธ ๊ฒƒ์„ ์ฐพ๊ธฐ $x('//*[text()="๋„ค์ด๋ฒ„๋กœ ์ด์šฉํ•˜๊ธฐ"]') ์†์„ฑ(class๋‚˜ id) ๊ฐ’์ด ํŠน์ • ๋ฌธ์ž๋กœ ์‹œ์ž‘ํ•˜๋Š” ์š”์†Œ ์ฐพ๊ธฐ $x("//div[starts-with(@class,.. 2023. 5. 7.
ํŒŒ์ด์ฌ - ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ ์กฐ์ž‘(winreg) import winreg # ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ ํ‚ค ์ƒ์„ฑ key_path = r"Software\MyExampleKey" try: key = winreg.CreateKey(winreg.HKEY_CURRENT_USER, key_path) print("ํ‚ค ์ƒ์„ฑ ์„ฑ๊ณต") except: print("ํ‚ค ์ƒ์„ฑ ์‹คํŒจ") # ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ ํ‚ค์— ๊ฐ’ ์„ค์ • value_name = "ExampleValue" value_data = "Hello, Registry!" try: winreg.SetValueEx(key, value_name, 0, winreg.REG_SZ, value_data) winreg.CloseKey(key) print("๊ฐ’ ์„ค์ • ์„ฑ๊ณต") except: print("๊ฐ’ ์„ค์ • ์‹คํŒจ") # ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ ํ‚ค์—์„œ ๊ฐ’ ์ฝ๊ธฐ try.. 2023. 5. 5.
ํŒŒ์ด์ฌ - pyinstaller ๊ด€๋ฆฌ์ž ๊ถŒํ•œ์œผ๋กœ ์‹คํ–‰ ํ•˜๊ธฐ --uac-admin ์˜ต์…˜์„ ์ถ”๊ฐ€ํ•˜๊ณ  ๋นŒ๋“œ๋ฅผ ํ•˜๋ฉด ๊ด€๋ฆฌ์ž ๊ถŒํ•œ์œผ๋กœ ์‹คํ–‰์ด ๊ฐ€๋Šฅํ•˜๋‹ค. ์˜ˆ์‹œ pyinstaller -w --uac-admin test.py ์ถœ์ฒ˜: https://dev-dream.tistory.com/4 pyinstaller ๋กœ exe ๋งŒ๋“ค ๋•Œ ๊ด€๋ฆฌ์ž ๊ถŒํ•œ์œผ๋กœ ์‹คํ–‰ํ•˜๊ธฐ python ์œผ๋กœ ํ”„๋กœ๊ทธ๋žจ์„ ๋งŒ๋“ค๋ฉด exe (์‹คํ–‰ํŒŒ์ผ) ํ˜•ํƒœ๋กœ ๋ฐฐํฌํ•  ๊ฒฝ์šฐ๊ฐ€ ์žˆ๋‹ค. py2exe ๋ฅผ ์ฃผ๋กœ ์ผ๋Š”๋ฐ setup ํŒŒ์ผ ๋งŒ๋“œ๋Š”๊ฒŒ ๋ถˆํŽธํ–ˆ๋Š”๋ฐ pyinstaller ๋ฅผ ํ™œ์šฉํ•˜๋ฉด ์‰ฝ๊ฒŒ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค. pip3 install pyinstaller ๋กœ pyins dev-dream.tistory.com 2023. 5. 5.
ํŒŒ์ด์ฌ - ๋งฅ ์ฃผ์†Œ ๋ณ€๊ฒฝ(changeMAC) changeMAC.py (๊ด€๋ฆฌ์ž ๊ถŒํ•œ ํ•„์š”) from winreg import * import os, time def run(adapterName, adapterType="Wi-Fi"): aReg = ConnectRegistry(None, HKEY_LOCAL_MACHINE) aKey = OpenKey(aReg, r"SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}") oKey = None sValue = None for i in range(255): try: aValue_name = EnumKey(aKey, i) oKey = OpenKey(aKey, aValue_name) sValue = QueryValueEx(oK.. 2023. 5. 2.
์›นํ›„ํฌ(webhook) ์‚ฌ์ดํŠธ(requestcatcher.com, webhook.site) https://requestcatcher.com/ Request Catcher — record HTTP requests, webhooks, API calls Request Catcher will create a subdomain on which you can test an application. All requests sent to any path on the subdomain are forwarded to your browser in real time. requestcatcher.com https://webhook.site/ Webhook.site - Test, process and transform emails and HTTP requests This URL received over {{ appCon.. 2023. 3. 27.
์–ด์…ˆ๋ธ”๋ฆฌ์–ด - ๋ฆฌ๋ˆ…์Šค syscall๋กœ open, read, write ์‚ฌ์šฉ ๋ฆฌ๋ˆ…์Šค ์•„ํ‚คํ…์ฒ˜ ํ™•์ธ ๋ช…๋ น์–ด uname -a syscall ํ…Œ์ด๋ธ” https://chromium.googlesource.com/chromiumos/docs/+/master/constants/syscalls.md#x86_64-64_bit Chromium OS Docs - Linux System Call Table Linux System Call Table These are the system call numbers (NR) and their corresponding symbolic names. These vary significantly across architectures/ABIs, both in mappings and in actual name. This is a quick reference for p.. 2023. 3. 24.
C/C++ - DLL ๋งŒ๋“ค๊ธฐ, DLL ์‚ฌ์šฉํ•˜๊ธฐ (GCC) my_dll.c (DLL ๋งŒ๋“ค๊ธฐ) #include void func() { system("start www.google.com");} GCC DLL ๋นŒ๋“œ gcc -shared my_dll.dll -o my_dll.c run.c (DLL ์‚ฌ์šฉํ•˜๊ธฐ) #include #include typedef void(*dll_func)();int main(){ HINSTANCE hDLL = LoadLibrary("my_dll.dll"); if(hDLL == NULL){ printf("Failed to load DLL\n"); return 1; } dll_func func = (dll_func)GetProcAddress(hDLL, "func"); if(func ==.. 2023. 3. 23.
ํŒŒ์ด์ฌ - ์ฝ”๋“œ ๋‚œ๋…ํ™” ๋ณ€ํ™˜ ์‚ฌ์ดํŠธ(pyob.oxyry.com) https://pyob.oxyry.com/ Oxyry Python Obfuscator - The most reliable python obfuscator in the world Features Rename symbol names, includes variables, functions, classes, arguments, class private methods. The name replacer avoids a 1:1 mapping of cleartext names to obfuscated names, the same name may be converted to several different names within differen pyob.oxyry.com 2023. 3. 16.
ํŒŒ์ด์ฌ - ์บก์ฑ  ์ƒ์„ฑ๊ธฐ(captcha) ๋ชจ๋“ˆ ์„ค์น˜ pip install captcha ๊ธ€์ž ์ƒ์„ฑ ์˜ˆ์‹œ # Import the following modules from captcha.image import ImageCaptcha # Create an image instance of the given size image = ImageCaptcha(width = 280, height = 90) # Image captcha text captcha_text = 'GeeksforGeeks' # generate the image of the given text data = image.generate(captcha_text) # write the image on the given file and save it image.write(captcha_text, .. 2023. 3. 12.
์…€๋ ˆ๋‹ˆ์›€ - ํฌ๋กฌ๋“œ๋ผ์ด๋ธŒ ์ž๋™ ์„ค์น˜ ๋ชจ๋“ˆ ์„ค์น˜ pip install webdriver_manager from webdriver_manager.chrome import ChromeDriverManager def exec_chrom(): driver = webdriver.Chrome(service=Service(ChromeDriverManager().install())) return driver 2023. 3. 8.
ํŒŒ์ด์ฌ - pyinstaller์˜ RecursionError : maximum recursion depth exceeded ์˜ค๋ฅ˜ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ• pyinstaller -w --onefile main.py ์ด๋Ÿฐ ์˜ˆ์‹œ๋กœ main.py๋ฅผ exe๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ๊ณผ์ •์— RecursionError ์˜ค๋ฅ˜๊ฐ€ ์ƒ๊ฒผ๋‹ค๋ฉด .spec ํŒŒ์ผ์„ ์•„๋ž˜์ฒ˜๋Ÿผ ์ˆ˜์ • pyinstaller๋กœ ๋นŒ๋“œ๋ฅผ ํ•œ๋ฒˆ ํ•ด์ฃผ๋ฉด ๊ทธ ํด๋”์— main.spec์ด๋ผ๋Š” ํŒŒ์ผ์ด ํ•˜๋‚˜ ์ƒ๊ธฐ๋Š”๋ฐ ์ด๊ฑธ ์—ฐ๋‹ค. ์ƒ์œ„ ๋ถ€๋ถ„์—๋‹ค. (์ธ์ฝ”๋”ฉ ๋ฐ”๋กœ ์•„๋ž˜์—) # -*- mode: python ; coding: utf-8 -*- import sys sys.setrecursionlimit(5000) # ํ˜น์€ import sys ; sys.setrecursionlimit(sys.getrecursionlimit() * 5) ๋‘ ์ค„์„ ์ƒˆ๋กœ ์ถ”๊ฐ€ํ•œ๋‹ค. (sys.setrecursionlimit ํ•จ์ˆ˜๋Š” ์žฌ๊ท€ ํ˜ธ์ถœ์˜ ์ œํ•œ ์„ค์ •์ด๋ผ๊ณ  ํ•œ๋‹ค. ๊ธฐ.. 2023. 3. 8.
728x90