Skip to main content

Simplified python article discovery & extraction.

Project description

Inspired by requests for its simplicity and powered by lxml for its speed; newspaper is a Python 2 library for extracting & curating articles from the web.

Newspaper wants to change the way people handle article extraction with a new, more precise layer of abstraction. Visit our homepage at: Newspaper Docs.

Newspaper utilizes lxml and caching for speed. Also, everything is in unicode

>>> import newspaper

>>> cnn_paper ='') # ~15 seconds

>>> for article in cnn_paper.articles: # filters urls
>>>     print article.url


>>> print cnn_paper.size() # number of articles

>>> print cnn_paper.category_urls()
[u'', u'', u'' ...]

>>> print cnn_paper.feed_urls()
[u'', u'', ...]

The first step is to download() an article.

>>> first_article = cnn_paper.articles[0]


>>> print first_article.html # html fetched from download()
u'<!DOCTYPE HTML><html itemscope itemtype="http://...'

# we have not downloaded this article yet, it will fail
>>> print cnn_paper.articles[7].html

We may also extract meaningful content from the html, like authors, body-text.. You must called download() on the article before calling parse().

>>> first_article.parse()

>>> print first_article.text
u'Three sisters who were imprisoned for possibly...'

>>> print first_article.top_img

>>> print first_article.authors
[u'Eliott C. McLaughlin', u'Some CoAuthor']

>>> print first_article.title
u'Police: 3 sisters imprisoned in Tucson home'

Finally, you may extract out natural language properties from the text. You must have called both download() and parse() the article before calling nlp().

>>> first_article.nlp() # must be on an already parse()'ed article

>>> print first_article.summary
u'...imprisoned for possibly a constant barrage...'

>>> print first_article.keywords
[u'music', u'Tucson', ... ]

>>> print cnn_paper.articles[100].nlp() # fail, not been downloaded yet
Traceback (...
ArticleException: You must parse an article before you try to..

Some other news-source level functionality

>>> print cnn_paper.brand

>>> print cnn_paper.description
u' delivers the latest breaking news and information on the latest...'

>>>[:5] # top google trending terms
['Ned Vizzini', Brian Boitano', Crossword Inventor', 'Alex and Sierra', 'Claire Davis']

>>> newspaper.popular_urls()
['', '', '', ...]

^ Just a few friendly suggestions if you forget the popular news sites!


Unless told not to in the constructor via the is_memo_articles param (default true), newspaper automatically caches all category, feed, and article urls. This is both to avoid duplicate articles and for speed.

Suppose the above code has already been run on the cnn domain once. Previous
article urls are cached and dupes are removed so we only get new articles.

>>> import newspaper

>>> cnn_paper ='')
>>> cnn_paper.size()
60    # since we last ran build(), cnn published 60 new articles!

>>> # If you'd like to opt out of memoization, init newspapers with

>>> cnn_paper2 ='', is_memo=False)
>>> cnn_paper2.size()

Alternatively, you may use newspaper’s lower level Article api.

>>> from newspaper import Article

>>> article = Article('')

>>> print article.html
u'<!DOCTYPE HTML><html itemscope itemtype="http://...'

>>> article.parse()

>>> print article.text
u'The purpose of this article is to introduce...'

>>> print article.authors
[u'Martha Stewart', u'Bob Smith']

>>> print article.top_img

>>> print article.title
u'Thanksgiving Weather Guide Travel ...'

>>> article.nlp()

>>> print article.summary
u'...and so that's how a Thanksgiving meal is cooked...'

>>> print article.keywords
[u'Thanksgiving', u'holliday', u'Walmart', ...]

nlp() is expensive, as is parse(), make sure you actually need them before calling them on all of your articles! In some cases, if you just need urls, even download() is not necessary.

Newspaper stands on the giant shoulders of lxml, nltk, and requests. Newspaper also uses much of goose’s code internally.


  • News url identification
  • Text extraction from html
  • Keyword extraction from text
  • Summary extraction from text
  • Author extraction from text
  • Top Image & All image extraction from html
  • Top Google trending terms
  • News article extraction from news domain
  • Quick html downloads via multithreading

Get it now

$ pip install newspaper

# If you KNOW for sure you will use the natural language features, nlp(), you must
# download some seperate nltk corpora below, it may take a while!

$ curl | python2.7

Examples TODO

See more examples at the Quickstart guide.


Full documentation is available at Newspaper Docs.


  • Python >= 2.6 and <= 2.7*


MIT licensed. Also, view the LICENSE for our internally used libraries at: goose-license

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for newspaper, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size newspaper-0.0.3.macosx-10.8-intel.exe (8.9 MB) File type Windows Installer Python version any Upload date Hashes View
Filename, size newspaper-0.0.3.tar.gz (10.8 MB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page