Skip to main content

Newspaper3k library with no download phase

Project description

Newspaper-no-download: Article scraping & curation

.. image::
:alt: Latest version

.. image::
:alt: Build status

.. image::
:alt: Coverage status

Inspired by `requests`_ for its simplicity and powered by `lxml`_ for its speed:

"Newspaper is an amazing python library for extracting & curating articles."
-- `tweeted by`_ Kenneth Reitz, Author of `requests`_

"Newspaper delivers Instapaper style article extraction." -- `The Changelog`_

.. _`tweeted by`:
.. _`The Changelog`:

**Newspaper is a Python3 library**! Or, view our **deprecated and buggy** `Python2 branch`_

.. _`Python2 branch`:

A Glance:

.. code-block:: pycon

>>> from newspaper import Article

>>> url = ''
>>> article = Article(url)

.. code-block:: pycon


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

.. code-block:: pycon

>>> article.parse()

>>> article.authors
['Leigh Ann Caldwell', 'John Honway']

>>> article.publish_date
datetime.datetime(2013, 12, 30, 0, 0)

>>> article.text
'Washington (CNN) -- Not everyone subscribes to a New Year's resolution...'

>>> article.top_image

>>> article.movies
['', ...]

.. code-block:: pycon

>>> article.nlp()

>>> article.keywords
['New Years', 'resolution', ...]

>>> article.summary
'The study shows that 93% of people ...'

.. code-block:: pycon

>>> import newspaper

>>> cnn_paper ='')

>>> for article in cnn_paper.articles:
>>> print(article.url)

>>> for category in cnn_paper.category_urls():
>>> print(category)

>>> cnn_article = cnn_paper.articles[0]
>>> cnn_article.parse()
>>> cnn_article.nlp()

.. code-block:: pycon

>>> from newspaper import fulltext

>>> html = requests.get(...).text
>>> text = fulltext(html)

Newspaper has *seamless* language extraction and detection.
If no language is specified, Newspaper will attempt to auto detect a language.

.. code-block:: pycon

>>> from newspaper import Article
>>> url = ''

>>> a = Article(url, language='zh') # Chinese

>>> a.parse()

>>> print(a.text[:150])
意图和动机。 一些亲北京阵营议员欢迎梁振英道歉,

>>> print(a.title)

If you are certain that an *entire* news source is in one language, **go ahead and use the same api :)**

.. code-block:: pycon

>>> import newspaper
>>> sina_paper ='', language='zh')

>>> for category in sina_paper.category_urls():
>>> print(category)

>>> article = sina_paper.articles[0]
>>> article.parse()

>>> print(article.text)
新浪武汉汽车综合 随着汽车市场的日趋成熟,
另一种轻松的新兴 车模式――金融购车正逐步成为时下消费者购

>>> print(article.title)
两年双免0手续0利率 科鲁兹掀背金融轻松购_武汉车市_武汉汽


Check out `The Documentation`_ for full and detailed guides using newspaper.

Interested in adding a new language for us? Refer to: `Docs - Adding new languages <>`_


- Multi-threaded article download framework
- News url identification
- Text extraction from html
- Top image extraction from html
- All image extraction from html
- Keyword extraction from text
- Summary extraction from text
- Author extraction from text
- Google trending terms extraction
- Works in 10+ languages (English, Chinese, German, Arabic, ...)

.. code-block:: pycon

>>> import newspaper
>>> newspaper.languages()

Your available languages are:
input code full name

ar Arabic
ru Russian
nl Dutch
de German
en English
es Spanish
fr French
he Hebrew
it Italian
ko Korean
no Norwegian
pl Polish
pt Portuguese
sv Swedish
hu Hungarian
fi Finnish
da Danish
zh Chinese
id Indonesian
vi Vietnamese
tr Turkish
el Greek
uk Ukrainian

Get it now

Run ✅ ``pip3 install newspaper3k`` ✅

NOT ⛔ ``pip3 install newspaper`` ⛔

On python3 you must install ``newspaper3k``, **not** ``newspaper``. ``newspaper`` is our python2 library.
Although installing newspaper is simple with `pip <>`_, you will
run into fixable issues if you are trying to install on ubuntu.

**If you are on Debian / Ubuntu**, install using the following:

- Install ``pip3`` command needed to install ``newspaper3k`` package::

$ sudo apt-get install python3-pip

- Python development version, needed for Python.h::

$ sudo apt-get install python-dev

- lxml requirements::

$ sudo apt-get install libxml2-dev libxslt-dev

- For PIL to recognize .jpg images::

$ sudo apt-get install libjpeg-dev zlib1g-dev libpng12-dev

NOTE: If you find problem installing ``libpng12-dev``, try installing ``libpng-dev``.

- Download NLP related corpora::

$ curl | python3

- Install the distribution via pip::

$ pip3 install newspaper3k

**If you are on OSX**, install using the following, you may use both homebrew or macports:


$ brew install libxml2 libxslt

$ brew install libtiff libjpeg webp little-cms2

$ pip3 install newspaper3k

$ curl | python3

**Otherwise**, install with the following:

NOTE: You will still most likely need to install the following libraries via your package manager

- PIL: ``libjpeg-dev`` ``zlib1g-dev`` ``libpng12-dev``
- lxml: ``libxml2-dev`` ``libxslt-dev``
- Python Development version: ``python-dev``


$ pip3 install newspaper3k

$ curl | python3


If you'd like to contribute and hack on the newspaper project, feel free to clone
a development version of this repository locally::

git clone git://

Once you have a copy of the source, you can embed it in your Python package,
or install it into your site-packages easily::

$ pip3 install -r requirements.txt
$ python3 install

Feel free to give our testing suite a shot, everything is mocked!::

$ python3 tests/

Planning on tweaking our full-text algorithm? Add the ``fulltext`` parameter::

$ python3 tests/ fulltext


View a working online demo here:
This is another working online demo:


Authored and maintained by `Lucas Ou-Yang`_.

``_ sponsored some work on newspaper, specifically focused on
automatic extraction.

Newspaper uses a lot of `python-goose's`_ parsing code. View their license `here`_.

Please feel free to `email & contact me`_ if you run into issues or just would like
to talk about the future of this library and news extraction in general!

.. _`Lucas Ou-Yang`:
.. _`email & contact me`:
.. _`python-goose's`:
.. _`here`:

.. _`Quickstart guide`:
.. _`The Documentation`:
.. _`lxml`:
.. _`requests`:
.. _``:

Project details

Release history Release notifications

This version
History Node


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
newspaper_no_download-0.0.1-py2.py3-none-any.whl (206.7 kB) Copy SHA256 hash SHA256 Wheel py2.py3
newspaper_no_download-0.0.1.tar.gz (196.4 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page