위키피디아 파이썬 크롤링


  • ()
  • 's Avatar 이 글의 작성자
  • Visitor
  • Visitor
18 Apr 2022 05:26 - 21 Jul 2023 08:41 #17892 작성자:
님의 글: 위키피디아 파이썬 크롤링
import wikipediaapi

wiki_wiki = wikipediaapi.Wikipedia('MyProjectName (이 이메일 주소가 스팸봇으로부터 보호됩니다. 확인하려면 자바스크립트 활성화가 필요합니다.)', 'ko')

page_py = wiki_wiki.page('페이지')
#print(page_py.text)

print("Page - Title: %s" % page_py.title)
print("Page - Summary: %s" % page_py.summary)

def print_sections(sections, level=0):
for s in sections:
print("%s: %s - %s" % ("*" * (level + 1), s.title, s.text[0:40]))
print_sections(s.sections, level + 1)


print_sections(page_py.sections)

#section_history = page_py.section_by_title('섹션')
#print("%s - %s" % (section_history.title, section_history.text))

section_transportation = page_py.section_by_title('섹션')
print("%s - %s" % (section_transportation.title, section_transportation.text))

page_py = wiki_wiki.page('페이지')
print("Page - Title: %s" % page_py.title)
print(page_py.summary)
Time to create page: 0.057 seconds
Powered by Kunena Forum