Python 6

[에러해결] Method Not Allowed The method is not allowed for the requested URL

에러 발생 Method Not Allowed The method is not allowed for the requested URL 데이터 저장 후 새로고침하는 과정에서 위와 같은 오류페이지가 떴다. 해당 method로의 요청을 허용하지 않는 API라는 뜻이라구 함 해결 방법 [app.py] @app.route('/', methods=["GET","POST"]) def home(): return render_template('index.html') methods를 GET, POST 둘 다 넣어주니 제대로 작동

Python 2023.05.18

[에러해결] WARNING: You are using pip version ...

에러 발생 WARNING: You are using pip version No module named 'bs4' bs4를 설치하는 중에 위와 같은 오류들이 발생했다. 뭐라는 건진 모르겠으나 찾아보니 최신버전 업데이트가 필요하고, 다시 깔아야 되는듯 해결 방법 버전 업그레이드 $ py -m pip install --upgrade pip 터미널에 하단 문구 입력하여 오류 확인 $ from bs4 import BeautifulSoup 기존에 설치된 BeautifulSoup4 삭제하기 $ py -m pip uninstall bs4 y 입력 Python이 설치된 파일 위치 찾기 시작메뉴에서 python 검색 우클릭 - 파일 위치 열기 설치파일 경로 복사 터미널에서 파이썬 설치 경로로 이동 $ cd 복사한 파일 경..

Python 2023.04.14

[Library] BeautifulSoup 크롤링

BeautifulSoup 라이브러리 설치 터미널에서 $ pip install bs4 크롤링 웹페이지에서 HTML중에 어떤 부분을 솎아내서 가지고 오는 것 크롤링 기본 세팅 import requests from bs4 import BeautifulSoup URL = "https://movie.daum.net/ranking/reservation" headers = {'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36'} data = requests.get(URL, headers=headers) soup = BeautifulSoup..

Python 2023.04.14

Python 기초

파일 생성 파일명.py 터미널에서 확인하기 작업창에서 마우스 우클릭 Run Python File in Terminal 주석 # 변수선언 a = 2 자료형 a = ['사과', '배', '감'] a[2] # 감 a = {'name' : '영수', 'age' : 24} a['name'] # 영수 함수는 콜론(:)과 들여쓰기로 표현 def sum(a, b, c): return a+b+c 조건문 age = 15 if age > 20: print('성인입니다') else: print('청소년입니다') 반복문 ages = [5, 10, 13, 23, 25, 9] for a in ages: print(a) 메서드 print('hi') : 터미널에서 hi 보여줌 .select_one('') : 하나만 선택해서 가져올 때..

Python 2023.04.14

Python 설치

파이썬(윈도우) 다운로드 https://www.python.org/ftp/python/3.8.6/python-3.8.6-amd64.exe Add Python 3.8 to PATH 체크 Install Now 눌러서 설치 Git bash 깃 배쉬 https://git-scm.com/ download for Windows 클릭 64-bit Git for Windows Setup 클릭 VSCode 익스텐션 설치 Python : 파이썬을 VSCode에서 쉽게 사용하게 해 줌 Git Bash 적용 상단 메뉴바의 터미널 - 새 터미널 플러스+버튼 옆 드롭다운에서 Select default profile(기본프로필 선택) 상단 드롭다운에서 Git Bash 누르기 가상환경 venv : 패키지를 담아두는 공구함 (== 라..

Python 2023.04.14