반응형
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | #-*-coding:utf-8 import pandas as pd import sys import time import datetime from bs4 import BeautifulSoup as bs import unicodedata import urllib.request as req def Main_Menu() : print() print("--------메뉴선택--------") print("\t1. 오늘의 주요 기사는?") print("\t2. 주간의 인기 뉴스") print("\t3. 기사 검색하기") print("\t0. 종료하기") print("----------------------") def Today_Main_Post() : return def Week_Hit_News() : url = "https://www.boannews.com/media/o_list.asp" res = req.urlopen(url) soup = bs(res,"html.parser") Hit_News_List = soup.select("#main_HitNews > ul > li > a ") i = 1 for ls in Hit_News_List : Hit_List = ls.string print("#%d >>"%i,Hit_List) i+=1 def Search_Article(name_article) : name_article_euc = name_article.encode("euc-kr") url = "https://www.boannews.com/search/news_list.asp?search=key_word&find="+name_article_euc res = req.urlopen(url) soup = bs(res,"html.parser") print(soup) return #eucStr = utfStr.decode('UTF-8').encode('EUC-KR','ignore') #bytearray(str, 'encoding').decode('another_encoding') while True : Main_Menu() menu_num = input("입력 : ") input_article = "" if int(menu_num) == 1 : Today_Main_Post() elif int(menu_num) == 2 : Week_Hit_News() elif int(menu_num) == 3: input_article = input("찾을 기사 제목 : ") Search_Article(input_article) elif int(menu_num) == 0 : break | cs |
반응형
'프로젝트' 카테고리의 다른 글
보안뉴스 웹크롤링(7) (0) | 2020.08.08 |
---|---|
보안뉴스 웹크롤링(6) (0) | 2020.08.07 |
보안뉴스 웹크롤링(4) (0) | 2020.08.05 |
보안뉴스 웹크롤링(3) (0) | 2020.07.16 |