简体   繁体   中英

Python Newspaper subheading

I want to extract the SUBHEADING of this and other articles: https://www.dr.dk/nyheder/regionale/trekanten/legos-regnskab-viser-tilbagegang

That is: "Lego har netop præsenteret regnskabet for 2017, og kurven peger nedad."

However, it doesn't seem like the python module Newspaper can do just that.

Am I missing something? Are there other modules that can? I've also tried readability and html2text.

My code:

from newspaper import Article

url = 'https://www.dr.dk/nyheder/regionale/trekanten/legos-regnskab-viser-tilbagegang'
article = Article(url)

article.download()
article.parse()

print (article.title)
print (article.text)

I think you should use:

print(article.meta_description)

which will print the subheading of the article.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM