collect · Wikipedia, weather, news (internet, Korean edition)

Note

Korean services only (Korean Wikipedia, Korea Meteorological Administration regions, a Korean news feed). The Global edition has no [Collect] block category. The Python module is still there, but it returns Korean text.

Fetches Wikipedia search results, weather information, and news from the internet.

Class: Wikipedia Weather News

class openpibo.collect.Wikipedia[source]

Bases: object

Functions: search() search_s()

Searches Wikipedia for a word.

example:

from openpibo.collect import Wikipedia

wiki = Wikipedia()
# 아래의 모든 예제 이전에 위 코드를 먼저 사용합니다.
search(search_text: str)[source]

Searches Wikipedia for search_text.

example:

result = wiki.search('강아지')
Parameters:

search_text (str) – Search term for Wikipedia

Returns:

Returns the content as an array of dictionaries. In most cases item ‘0’ holds the summary. Returns None if nothing is found. example:: [‘0’:{ ‘title’: ‘명칭’, ‘content’: “한국어 ‘강아지’는 ‘개’에 어린 짐승을 뜻하는 ‘아지’가 붙은 말이다…” }, … ] or None

search_s(search_text: str)[source]

Searches Wikipedia for search_text. (for blocks only)

example:

result = wiki.search_s('강아지')
Parameters:

search_text (str) – Search term for Wikipedia

Returns:

Returns a list containing only the content of the search function’s return value. In most cases item ‘0’ holds the summary. Returns None if nothing is found. example:: [ “한국어 ‘강아지’는 ‘개’에 어린 짐승을 뜻하는 ‘아지’가 붙은 말이다…”, … ] or None

class openpibo.collect.Weather[source]

Bases: object

Functions: search() search_s()

Searches for the general forecast and the weather for today/tomorrow/the day after tomorrow.

example:

from openpibo.collect import Weather

weather = Weather()
# 아래의 모든 예제 이전에 위 코드를 먼저 사용합니다.
region_list = {'강원': 105, '경기': 109, '경남': 159, '경북': 143, '광주': 156, '대구': 143, '대전': 133, '부산': 159, '서울': 109, '세종': 133, '울산': 159, '인천': 109, '전국': 108, '전남': 156, '전북': 146, '제주': 184, '충남': 133, '충북': 131}

Regions for which weather information can be searched.

search(search_region: str = '전국')[source]

Gets the weather information (general forecast, weather for today/tomorrow/the day after tomorrow) for the given region (`search_region`).

example:

result = weather.search('서울')
Parameters:

search_region (str) – Searchable region (default: 전국 (nationwide)) The searchable regions are:: ‘전국’, ‘서울’, ‘인천’, ‘경기’, ‘부산’, ‘울산’, ‘경남’, ‘대구’, ‘경북’, ‘광주’, ‘전남’, ‘전북’, ‘대전’, ‘세종’, ‘충남’, ‘충북’, ‘강원’, ‘제주’

Returns:

Returns the general forecast and the weather and minimum/maximum temperatures for today/tomorrow/the day after tomorrow. example:: { ‘forecast’: ‘내일 경기남부 가끔 비, 내일까지 바람 약간 강, 낮과 밤의 기온차 큼’ ‘today’: { ‘weather’: ‘전국 대체로 흐림’, ‘minimum_temp’: ‘15.3 ~ 21.6’, ‘highst_temp’: ‘23.1 ~ 27.6’ } ‘tomorrow’: { ‘weather’: ‘전국 대체로 흐림’, ‘minimum_temp’: ‘15.3 ~ 21.6’, ‘highst_temp’: ‘23.1 ~ 27.6’ } ‘after_tomorrow’: { ‘weather’: ‘전국 대체로 흐림’, ‘minimum_temp’: ‘15.3 ~ 21.6’, ‘highst_temp’: ‘23.1 ~ 27.6’ } } or None

search_s(search_region: str = '전국', search_type: str = 'forecast', search_item: str = 'weather')[source]

Gets the weather information (general forecast, weather for today/tomorrow/the day after tomorrow) for the given region (`search_region`).

example:

result = weather.search_s('서울')
Parameters:
  • search_region (str) – Searchable region (default: 전국 (nationwide)) The searchable regions are:: ‘전국’, ‘서울’, ‘인천’, ‘경기’, ‘부산’, ‘울산’, ‘경남’, ‘대구’, ‘경북’, ‘광주’, ‘전남’, ‘전북’, ‘대전’, ‘세종’, ‘충남’, ‘충북’, ‘강원’, ‘제주’

  • search_type (str) – Item to search (default: forecast) The searchable items are:: ‘forecast’, ‘today’, ‘tomorrow’, ‘after_tomorrow’

  • search_item (str) – Item to search (default: weather) The searchable items are:: ‘weather’, ‘minimum_temp’, ‘highst_temp’ If search_type is forecast, search_item is ignored.

Returns:

Depending on the parameters, returns the general forecast or the weather, minimum temperature, or maximum temperature for today/tomorrow/the day after tomorrow. example:: { ‘forecast’: ‘내일 경기남부 가끔 비, 내일까지 바람 약간 강, 낮과 밤의 기온차 큼’ ‘today’: { ‘weather’: ‘전국 대체로 흐림’, ‘minimum_temp’: ‘15.3 ~ 21.6’, ‘highst_temp’: ‘23.1 ~ 27.6’ } ‘tomorrow’: { ‘weather’: ‘전국 대체로 흐림’, ‘minimum_temp’: ‘15.3 ~ 21.6’, ‘highst_temp’: ‘23.1 ~ 27.6’ } ‘after_tomorrow’: { ‘weather’: ‘전국 대체로 흐림’, ‘minimum_temp’: ‘15.3 ~ 21.6’, ‘highst_temp’: ‘23.1 ~ 27.6’ } } or None

class openpibo.collect.News[source]

Bases: object

Functions: search() search_s()

Fetches news using the JTBC News RSS service.

example:

from openpibo.collect import News

news = News()
# 아래의 모든 예제 이전에 위 코드를 먼저 사용합니다.
topic_list = {'경제': 'economy', '국제': 'international', '뉴스랭킹': 'newsrank', '뉴스룸': 'newsroom', '문화': 'culture', '사회': 'society', '속보': 'newsflash', '스포츠': 'sports', '썰전 라이브': 'ssulzunlive', '아침&': 'morningand', '연예': 'entertainment', '정치': 'politics', '정치부회의': 'politicaldesk', '풀영상': 'fullvideo'}

Topics for which news can be searched.

search(search_topic: str = '뉴스랭킹')[source]

Gets news for the given topic (`search_topic`).

example:

result = news.search('속보')
Parameters:

search_topic (str) – Searchable news topic (default: 뉴스랭킹 (news ranking)) The searchable topics are:: ‘속보’, ‘정치’, ‘경제’, ‘사회’, ‘국제’, ‘문화’, ‘연예’, ‘스포츠’, ‘풀영상’, ‘뉴스랭킹’, ‘뉴스룸’, ‘아침&’, ‘썰전 라이브’, ‘정치부회의’

Returns:

An array of dictionaries with title, link, description, and pubDate elements. example:: [ { ‘title’: ‘또 소방차 막은 불법주차, 이번엔 가차없이 밀어버렸다’, ‘link’: ‘https://news.jtbc.joins.com/article/article.aspx?…’, ‘description’: ‘2019년 4월 소방당국의 불법주정차 강경대응 훈련 모습…, ‘pubDate’: ‘2021.09.03’ }, ] or None

search_s(search_topic: str = '뉴스랭킹', search_type: str = 'title')[source]

Gets news for the given topic (`search_topic`).

example:

result = news.search_s('속보')
Parameters:
  • search_topic (str) – Searchable news topic (default: 뉴스랭킹 (news ranking)) The searchable topics are:: ‘속보’, ‘정치’, ‘경제’, ‘사회’, ‘국제’, ‘문화’, ‘연예’, ‘스포츠’, ‘풀영상’, ‘뉴스랭킹’, ‘뉴스룸’, ‘아침&’, ‘썰전 라이브’, ‘정치부회의’

  • search_type (str) – Item to search (default: title) The searchable items are:: ‘title’, ‘link’, ‘description’

Returns:

A list of the selected element (title, link, or description) example:: [ ‘또 소방차 막은 불법주차, 이번엔 가차없이 밀어버렸다’, … ] or None