Python 17

streamlit - python으로 간단하게 웹사이트를 만들어주는 라이브러리

https://streamlit.io/ Streamlit • A faster way to build and share data appsStreamlit is an open-source Python framework for data scientists and AI/ML engineers to deliver interactive data apps – in only a few lines of code.streamlit.io 예제:import streamlit as stst.title('Uber pickups in NYC')  실행 명령어터미널에 아래의 명령어를 적어준다. python -m streamlit run .\(해당 파이썬파일).py  이 사이트에서 데이트베이스의 데이터를 표형태로 출력하게 해줄수있다.

Python 2024.12.23

ai로 응답을 json형식으로 받을때 JSONDecoder에러시

이전까지는 ai에서 응답을 받을시 json형식으로 받게되면 깨져서 응답이 오거나 json형식이 아니게 오는일이 있었다. 하지만 2024년 8월 6일 Structured Outputs이라는 기능의 추가로 거의 100프로의 확률로 json값으로 정상적으로 날아올수있게 강제로 형식를 json으로 받게 만들어줄수 있는 기능이 open ai에 추가되었다. 아래사이트에 추가적인 사용방법이 적혀있다.  참조: https://openai.com/index/introducing-structured-outputs-in-the-api/

Python 2024.12.23

영상의 자막을 이용하여 내용을 추출하기(유튜브)

영상 그 자체를 사용하여 영상 내용을 ai에게 분석을 부탁할 수도 있겠지만. 아직은 영상을 이용하는 방법은 token비용이 너무 많이 들어가기 때문에 영상에 사용되는 자막을 이용하는 방법이 많이 사용된다.  https://github.com/jdepoix/youtube-transcript-api GitHub - jdepoix/youtube-transcript-api: This is a python API which allows you to get the transcript/subtitles for a given YouTuThis is a python API which allows you to get the transcript/subtitles for a given YouTube video. It also..

Python 2024.12.23

git hub에 업로드시 .gitignore 세팅법

https://www.toptal.com/developers/gitignore/ gitignore.ioCreate useful .gitignore files for your projectwww.toptal.com추가해야되는것들1. 쓰는언어(java, python)2. 빌드도구(gradle, maven)3. 쓰는툴(intellij+all, visual studio code+all)4. os(windows, mac os 둘다 추가해주자) 민감한 개인정보는 보통 환경변수를 이용하여 온라인상에는 업로드하지 말아야하는데 아래의 .gitignore코드를 추가해주자  javascript# Logslogs*.lognpm-debug.log*yarn-debug.log*yarn-error.log*lerna-debug.log..

Python 2024.12.22

chromedriver 사용시

from selenium import webdriverbrowser = webdriver.Chrome()browser.get("사이트이름")이제 구글에서 따로 chromedriver를 다운받지않고 pip install selenium하고 webdriver.Chrome()으로 실행해주면 자동으로 크로미움이 작동된다.   # 크로미움 실행시 창이 꺼지는 문제아래와같은 코드를 추가해주면된다. 혹은 주피터노트북으로 꺼짐 방지옵션을 실행 from selenium import webdriver# 꺼짐방지 옵션from selenium.webdriver.common.by import Byfrom selenium.webdriver.chrome.options import Optionschrome_options = Opti..

Python 2024.12.03

Requests vs Selenium

# Requests 호출하기 쉽다 하지만 덜 직관적이라 안되는 경우가 많다. import requests url = "https://finance.naver.com/" res = requests.get(url) print(res.text) # 바로 데이터를 가지고 올 수 있었다. # Selenium 사람이 화면에서 작동하는 것처럼 쓸 수 있다. 다루기가 어렵지만 직관적이라 Requests에서 안되는 것들을 해결할 수 있다. chromedriver_autoinstaller.ins driver = webdriver.Chrome() driver.implicity_wait(3) Url = "https://www.instagram.com/" driver.get(url=Url)

Python 2023.08.29