부-하
오늘 벌써 13일차네요..
저 드디어 손톱 깎았습니다.
이제 타자 치는거 두렵지 않아요.
수업 시작.~!
오늘부터는,, 데이터 수집 및 크롤링에 대해서 배워볼거에용,,
일단 데이터가 있다고 치면
데이터는 가공하기 전의 순수한 상태의 자료들입니다.
정보는 유의미하게 가공된 2차 데이터입니다.
지식은 정보들 간의 관계를 통해 얻은 가치 있는 정보들입니다.
마지막으로 지혜는 지식을 활용하는 창의적인 아이디어입니다!
데이터 분석이 필요한 이유는
1. 데이터는 근거가 되는 정보를 담고 있고
2. 데이터를 통해 경험을 얻을 수 있고
3. 데이터를 통해 새로운 가치를 창출 가능하기 때문이라고 하네용.
문득
수업을 듣고있는데
전필로 들었던 데이터 사이언스 과정이 생각나는,, 수업이네용..
데이터를 제공하는 사이트 몇개를 소개해 주셨어용
공공데이터 포털
국가에서 보유하고 있는 다양한 데이터를『공공데이터의 제공 및 이용 활성화에 관한 법률(제11956호)』에 따라 개방하여 국민들이 보다 쉽고 용이하게 공유•활용할 수 있도록 공공데이터(Datase
www.data.go.kr
열린데이터광장 메인
데이터분류,데이터검색,데이터활용
data.seoul.go.kr
https://kosis.kr/index/index.do
KOSIS 국가통계포털
내가 본 통계표 최근 본 통계표 25개가 저장됩니다. 닫기
kosis.kr
통합 데이터지도 – 공공 민간 빅데이터 통합 검색
통합 데이터지도는 빅데이터 플랫폼 및 센터가 생산 유통한 공공‧민간 데이터를 쉽게 연계∙활용할 수 있도록 합니다. 데이터를 친숙하게 이용하고 나아가 데이터 거래의 장을 구축하여 데이
www.bigdata-map.kr
AI-Hub
자세히보기 AI 허브가 추천하는 검색어입니다. 태그를 클릭하여 검색결과를 확인하세요.
aihub.or.kr
https://datasetsearch.research.google.com/
Dataset Search
datasetsearch.research.google.com
웹의 동작 순서..
웹에 있는 정보를 보기 위해 먼저 하는 일은 웹 브라우저를 시작하고, 거기에 주소 정보를 입력하는 것입니다...
주소 정보의 공식 이름은 URL이라고 합니다!
와 대박!
대박이다............
html 너무 오랜만이고,, 재밋고,, 깜찍해요!
개쩐다;; 코딩 개천재;;
거친,, 웹 크롤링 세계..
url을 다양한 방법으로 표현할 수 있는데
두번째 방법이 응용하기 가장 괜찮고 좋아용.
연습문제,, 시작..^^
#변수로 페이지를 지정해서 5번째 페이지를 읽어오세요.
page = 10 #페이지
start = (page-1) * 10 + 1
url = f"https://search.naver.com/search.naver?where=news&sm=tab_pge&query=%EC%9D%B8%EA%B3%B5%EC%A7%80%EB%8A%A5&sort=0&photo=0&field=0&pd=0&ds=&de=&cluster_rank=100&mynews=0&office_type=0&office_section_code=0&news_office_checked=&nso=so:r,p:all,a:all&start=" + str(start)
response = requests.get(url)
html = response.text
bs_obj = BeautifulSoup(html, "html.parser")
titles = bs_obj.select('.news_tit')
for title in titles:
print(title.text)
#page를 넣으면 그 페이지의 뉴스를 가져오는 함수를 만들고, 그 함수를 호출하세요.
def new_page(n):
page = n
start = (page-1) * 10 + 1
url = f"https://search.naver.com/search.naver?where=news&sm=tab_pge&query=%EC%9D%B8%EA%B3%B5%EC%A7%80%EB%8A%A5&sort=0&photo=0&field=0&pd=0&ds=&de=&cluster_rank=100&mynews=0&office_type=0&office_section_code=0&news_office_checked=&nso=so:r,p:all,a:all&start=" + str(start)
response = requests.get(url)
html = response.text
bs_obj = BeautifulSoup(html, "html.parser")
titles = bs_obj.select('.news_tit')
for title in titles:
print(title.text)
new_page(5)
#위 함수에서 키워드도 매개변수로 넘겨받아 다른 키워드에 대해서도 검색할 수 있게 수정
def new_page(page, keyword):
start = (page-1) * 10 + 1
url = f"https://search.naver.com/search.naver?where=news&sm=tab_pge&query="+keyword+"&sort=0&photo=0&field=0&pd=0&ds=&de=&cluster_rank=100&mynews=0&office_type=0&office_section_code=0&news_office_checked=&nso=so:r,p:all,a:all&start=" + str(start)
response = requests.get(url)
html = response.text
bs_obj = BeautifulSoup(html, "html.parser")
titles = bs_obj.select('.news_tit')
for title in titles:
print(title.text)
new_page(5,"인공지능")
#키워드와 페이지번호를 사용자로부터 입력 받아서, 그 키워드, 그 페이지를 읽어오세요.
def new_page(page, keyword):
start = (page-1) * 10 + 1
url = f"https://search.naver.com/search.naver?where=news&sm=tab_pge&query="+keyword+"&sort=0&photo=0&field=0&pd=0&ds=&de=&cluster_rank=100&mynews=0&office_type=0&office_section_code=0&news_office_checked=&nso=so:r,p:all,a:all&start=" + str(start)
response = requests.get(url)
html = response.text
bs_obj = BeautifulSoup(html, "html.parser")
titles = bs_obj.select('.news_tit')
for title in titles:
print(title.text)
s = input("원하는 키워드를 입력해주세요 :")
n = int(input("원하는 페이지를 입력해주세요 :"))
print('-'*50)
new_page(n, s)
#키워드와 페이지를 입력 받음. 페이지 번호가 4라면 1~4페이지를 읽어온다.
#처음부터 입력한 페이지까지 출력
def new_page(page, keyword):
start = 1
for i in range(page):
start = i * 10 + 1
url = f"https://search.naver.com/search.naver?where=news&sm=tab_pge&query="+keyword+"&sort=0&photo=0&field=0&pd=0&ds=&de=&cluster_rank=100&mynews=0&office_type=0&office_section_code=0&news_office_checked=&nso=so:r,p:all,a:all&start=" + str(start)
response = requests.get(url)
html = response.text
bs_obj = BeautifulSoup(html, "html.parser")
titles = bs_obj.select('.news_tit')
for title in titles:
print(title.text)
print("--페이지 전환--")
i = i+1
s = input("원하는 키워드를 입력해주세요 :")
n = int(input("몇 번째 페이지까지 읽어오시겠습니까? :"))
print('-'*50)
new_page(n, s)
#3개의 키워드를 다 검색하고 싶다.(예. '인공지능 파이썬 대전')
#페이지 번호는 1번만 입력.
def new_page(keyword):
start = 1
for i in keyword.split():
url = f"https://search.naver.com/search.naver?where=news&sm=tab_pge&query="+i+"&sort=0&photo=0&field=0&pd=0&ds=&de=&cluster_rank=100&mynews=0&office_type=0&office_section_code=0&news_office_checked=&nso=so:r,p:all,a:all&start=" + str(start)
response = requests.get(url)
html = response.text
bs_obj = BeautifulSoup(html, "html.parser")
titles = bs_obj.select('.news_tit')
for title in titles:
print(title.text)
print("--다른키워드 전환--")
keyword = input("원하는 키워드를 입력해주세요 :")
print('-'*50)
new_page(keyword)
와다다다닫다다다
사실은 점심은 이미 먹었어요..
근데 연습문제가 너무 많아서,,
일단 점심 사진 고.
오늘도 쭈꾸미. 고.
오늘은 순한맛 먹었습니다..^^
우리 애기입맛 있으셔서...
오는길에 사진도 찍었어용..
근데 사진은 비밀이고
벚꽃사진만 냅다 드릴게영 ㅎㅎ
예쁘다.!
그리고 시작된 공부...
달렷
정규표현식이란 일종의 문자를 표현하는 공식으로, 특정 규칙이 있는 문자열 집합을 추출할 때
자주 사용하는 기법이다
라고 합니당 ^^!
RegExr: Learn, Build, & Test RegEx
RegExr is an online tool to learn, build, & test Regular Expressions (RegEx / RegExp).
regexr.com
이곳에서 정규표현식을 연습할 수 있습니당!
정규 표현식 문법에는 다양한게 있어용..
반복 관련 메타문자에는 -, +, *, ?, {}이 있네용...............
그외 메타문자는 (), ., |, ^, $, \이 있습니다.
저는 이만 도망가겠습니다.
아디오스
'공부 > ABC 부트캠프' 카테고리의 다른 글
ABC 부트캠프 15일차 (0) | 2023.03.31 |
---|---|
ABC 부트캠프 14일차 (0) | 2023.03.30 |
ABC 부트캠프 12일차 (0) | 2023.03.28 |
ABC 부트캠프 10일차 (0) | 2023.03.24 |
ABC 부트캠프 9일차 (0) | 2023.03.23 |