본문 바로가기

전체 글97

크롤링 (2) 1. 프렌즈 드라마 분석 # 드라마 텍스트 가공 (Do it 파이썬 생활프로그래밍) 초판 2020: 52페이지 # friends.txt를 다운받아서 같은 폴더에 넣은 다음 프로그램을 실행합니다. import os, re, codecs #자신의 저장경로를 입력해야 합니다. os.chdir(r'D:/pythonclass') f = open('friends101.txt', 'r', encoding = 'utf-8') script101 = f.read() # 문자열 객체 슬라이싱 print(script101[:100]) Line = re.findall(r'Monica:.+', script101) #리스트 요소 중 앞에서 3개까지만 출력 print(Line[:3]) # 모니카의 대사만 모으기 Line = re.f.. 2021. 6. 25.
Crawling and Flask (2) =============================================== 크롤링 요청 페이지 작성 =============================================== c:\dev> tree /F Flask4Crawling2 Web. │ app.py │ ├─static │ index.css │ └─templates index.html result.html index.html index.css < ---------------- Form Grid Crea.. 2021. 6. 25.
셀레늄 설치 1. 셀레늄 pip 설치하기 cmd창에 pip install -U selenium 입력 2. SeleniumHQ Browser Automation 접속 후 pip 다운로드 3. 크롬 설정 -> 버전 확인 91.0.4472.114 4. https://sites.google.com/a/chromium.org/chromedriver/downloads 접속 후 버전에 맞는거 설치 5. 파이썬 폴더에 옮기기 아톰 설정 Settings - Packages - Hydrogen - Settings 예제 1 selenium #* open a new Chrome browser # * load the page at the given URL from selenium import webdriver browser = web.. 2021. 6. 25.
Crawling and Flask 예제 1 weather style.css .naver_weather { padding: 20px; border: 10px solid blue; border-radius: 50px; } index.html {% for i in list %} {{ i }} {% endfor %} app.py from flask import Flask, render_template import crawling app = Flask(__name__) @app.route('/') def index(): naver_weather = crawling.naver_weather() return render_template("index.html", list=naver_weather) if __name__ == '__main__': app.. 2021. 6. 24.