자동화된 방법으로 웹을 탐색하고 데이터를 수집하는 작업
크롬에 기본 탑재된 웹 개발 및 디버깅 도구
requests
HTTP 요청/응답 처리 모듈 BeautifulSoup
Python library for pulling data out of HTML and XML file requests.get()
requests.post()
UTF-8
, EUC-KR
)(Chrome Developer Tools) 크롬 브라우저에 기본 탑재된 웹 개발 및 디버깅 도구
요소(Element): 웹 페이지 구성 요소 살펴보는 기능
네트워크(Network): 브라우저와 서버 사이의 요청과 응답 살펴보는 기능
import requests
from bs4 import BeautifulSoup
url = "<https://www.google.com/search?q=삼성전자>"
r = requests.get(url)
soup = BeautifulSoup(r.text)
soup.title.text
headers = {
'user-agent': 'AppleWebKit Chrome/74',
'accept-language': 'ko'
}
r = requests.get(url, headers=headers)
soup = BeautifulSoup(r.text)
a_list = soup.find_all('a')
for a in a_list:
print(a.text)
http://companyinfo.stock.naver.com/v1/company/c1010001.aspx?cmp_cd=005930
code = '005930'
url = '<http://companyinfo.stock.naver.com/v1/company/c1010001.aspx?cmp_cd=>' + code
r = requests.get(url)
soup = BeautifulSoup(r.text,"lxml")
td = soup.find('td', {'class':'cmp-table-cell td0101'})
td
td.find('span', {'class':'name'}).text
anchors = td.find_all('a', {'class':'cEm'})
print(anchors[0]['href'])
print(anchors[1]['title'].replace('\\r', ''))
dts = td.find_all('dt', {'class':'line-left'})
print(dts[0].text)
print(dts[1].text)
print(dts[2].text)
https://finance.naver.com/marketindex/ (시장지표)
윈도우 운영체제의 노트북에서는 iPhone 유선 테더링이 잘 안되는 경우가 많습니다. 보통 iPhone의 드라이버가 설치가 안되있어서인…
안녕하세요, 혹시 이런 생각해 본 적 없으신가요? "내가 투자한 회사는 누가 감시하고, 어떻게 운영될까?" 오늘은…
1. Gemini CLI란 무엇인가요? Gemini CLI는 터미널 환경에서 직접 Gemini 모델과 상호작용할 수 있도록 만들어진…
과적합은 머신러닝에서 학습용데이터를 과하게 학습하여, 실제데이터를 예측하지 못하는 현상을 말합니다. 인공지능(AI)의 학습 방법은 우리가 시험공부를…