Skip to main content

Newspaper3K

Published 1 min readMarkdown
Part of seriesPython
  • Reference : https://news.naver.com/main/read.nhn?mode=LSD&mid=sec&sid1=101&oid=030&aid=0002881076
  • Install newspaper3k package. !pip install newspaper3k

News data scrapping code

# Import module 'Article' from 'newspaper' package
from newspaper import Article

# News link for crawling
url = 'https://news.naver.com/main/read.nhn?mode=LSD&mid=sec&sid1=101&oid=030&aid=0002881076'

# Set a language based on the news. For Korean, language='ko' 
article = Article(url, language='ko')

# Download the news,
article.download()
# And look for the title and body of the news.
article.parse()

It does not print anything. To see how it's parsed, you need to run print(article.title) and print(article.text)

print(article.title)

image.png

print(article.text)

image.png

No comments yet. Be the first to comment.

More from this blog