Python/Python 웹 크롤링

    Python - cine21 데이터 크롤링

    1. 씨네 21에 있는 배우 정보를 크롤링 해보자 1. 씨네21 홈페이지에 접속 http://www.cine21.com/rank/person 씨네21 대한민국 최고 영화전문매체 www.cine21.com - 1개월치 데이터를 가져올 예정 (이름, 흥행지수, 순위, 출연자, 직업, 성별, 신장/체중, 취미 등등...) 2. 개발자도구 -> content클릭 -> Request URL에 있는 URL이 진짜 URL임. request로 가져올 때 저 URL사용해야함 3. Post방식으로 전달하기 때문에 전달하는 Form Data값 확인(개발자도구 -> content클릭 -> 아래로 내리면 있음) 4. HTML돔 확인한 후 배우의 이름과 각 페이지 URL들을 가져오자!! site 주소 : http://www.ci..

    Selenium

    1. Selenium이란? https://selenium-python.readthedocs.io/ Selenium with Python — Selenium Python Bindings 2 documentation Note This is not an official documentation. If you would like to contribute to this documentation, you can fork this project in Github and send pull requests. You can also send your feedback to my email: baiju.m.mail AT gmail DOT com. So far 40+ community selenium-python.readthe..

    파이썬 OpenAPI_07월 24일

    1. Melon 100 Chart 스크래핑 100곡 노래의 title, id 추출 Song의 Detial 페이지로 100번 요청해서 상세정보 추출 Pandas의 DataFrame에 저장 DB에 Song Table로 저장 - 100곡 노래의 title, id 추출 * 멜론의 경우 user_agent가 필요!! - 멜론에서 그렇게 걸어놈 ㅇㅅㅇ - 로봇이 아님을 증명하기 위해 사용 import requests from bs4 import BeautifulSoup import re url = 'https://www.melon.com/chart/index.htm' request_header = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWe..

    파이썬 OpenAPI_07월 23일

    Pandas 1. iloc[] 사용(원하는 index줘서 선택) ** data/data_draw_korea.csv사용 data = pd.read_csv('data/data_draw_korea.csv') - iloc[] : column index, row index 줌 # iloc[]사용 data.iloc[0:3,0:3] - iloc 또한 2개 간격으로 출력 가능~!! data.iloc[0:20:2,0:3] - unique() : 중복제거 : 광역시도 중복제거하기 # 광역시도 이름 확인(중복된 이름 빼고) print(data['광역시도'].unique()) - unique() : 중복제거 : 행정구역 중복제거하기 print(data['행정구역'].unique()) - sample(원하는 갯수) : 원하는 ..

    파이썬 OpenAPI_07월 22일

    1. 웹 설명 1. html(Hyper Text Markup Language) 2. DOM(Document Object Model) - dom tree - traversing, traverse(순회) - manipulation(조작) : tree변경 3. 특정 문자열 가져오기 - 방법1 : 정규표현식 - 방법2 : HTML Parser라이브러리 (ex)BeautifulSoup4, lxml ​ 2. 웹툰 회차별 이미지 다운로드 - 제목, 회차, url을 입력받는 함수 정의 #title(제목), 회차, url 을 입력 받아서 저장하는 함수 정의 import os import requests from bs4 import BeautifulSoup def write_image(title,seq, url): #ur..

    파이썬 OpenAPI_07월 21일

    참고 문서 https://realpython.com/python-requests/ Python’s Requests Library (Guide) – Real Python In this tutorial on Python's "requests" library, you'll see some of the most useful features that requests has to offer as well as how to customize and optimize those features. You'll learn how to use requests efficiently and stop requests to external serv realpython.com - 웹툰 이미지 크롤링 1. 네이버 웹툰 이미지 다운로드 ..

    파이썬 OpenAPI_07월 20일

    1. Anaconda 설치 : python 기본 toolkit + 외부 라이브러리 : 관리자 권한으로 실행 : path 우선순위 변경 2. Editor : Jupiter Notebook 사용 CLI(Command Line Interface) 방식 : python idle >>> : ipython 을 기반으로 해서 Browser 상에 사용하는 에디터 : chrome브라우저가 기본 브라우저로 설정되어 있어야 함 파일 - Pickle - Built - in module - 파일 자체가 텍스트가 아닌 바이너리 파일로 저장됨(mode = wb) - dump함수 - 피클에 있는 저장함수 - load함수 - 저장된 파일을 불러오는 함수 - 언제사용? object를 파일로 저장했다 불러올 경우 [pickle_dump...

    파이썬 수업_07월 17일

    캡슐화 - 왜 써야하나? : 잘못된 값을 넣지 못하게 하기 위해 ex ) myDate = MyDate(2001, 13, 34) //년, 월, 일 _ 잘못된 값 들어감 - 사용법 * java --> private 사용 * python --> self.__year = year 과 같이 사용 : python 에서는 클래스 내부에서만 사용되는 변수 언더바 2개 - __year 사용 - 변수 불러올 때 * java --> getter, setter * python --> 아래와 같이 사용, 항상 getter가 먼저 선언되어있어야 하고, 쌍을 이루어 같이 선언되어있어야함 # getter @property def year(): return self.__year # setter @year.setter def year(..