자동화된 방법으로 웹을 탐색하고 데이터를 수집하는 작업
크롬에 기본 탑재된 웹 개발 및 디버깅 도구
requestsHTTP 요청/응답 처리 모듈 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/ (시장지표)
요양원 선택 전 반드시 확인해야 할 체크리스트를 공개합니다. 공식 평가 자료 조회법, 방문 시 확인…
공공기관 채용 비리의 실태와 피해 지원자의 대응법을 정리했습니다. 채용 비리 신고 방법, 공익신고자 보호제도, 취준생…
주식 손실을 세금 절약에 활용하는 합법적 방법을 공개합니다. 해외주식 손익통산, ISA 계좌 활용, 연금계좌 절세까지…
배달이 예상 시간보다 크게 늦으면 취소·환불을 요청할 수 있습니다. 배달앱별 지연 취소 방법과 잘못 배달됐을…
통신비 절약의 핵심은 요금제 최적화입니다. 내 데이터 사용량 확인법, 알뜰폰 전환 비교, 위약금 없이 요금제…