Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
25daa2b
Merge pull request #71 from codelucas/huge-refactor-codelucas
codelucas Aug 5, 2014
3053ea2
[bugfix] Removed bad reference in setup.py
codelucas Aug 6, 2014
d6d1613
[bugfix] Fix wrong equality comparision
codelucas Aug 6, 2014
6aa85d8
Add slash splitter
igor-shevchenko Aug 15, 2014
6da4fa9
Remove unneeded files
codelucas Oct 12, 2014
4e31fc3
Update version from 0.0.7 to 0.0.8
codelucas Oct 12, 2014
b9dac8d
Revamped all unit tests so that every request is mocked (unit tests w…
codelucas Oct 12, 2014
eec1127
Reformat setup.py, remove unused code
codelucas Oct 12, 2014
b03912e
Remove CHANGES.txt and reformat CONTRIBUTORS.md
codelucas Oct 12, 2014
04a8881
Update installation instructions in README.rst
codelucas Oct 12, 2014
00a481a
Reflect new installation directions in the site user docs
codelucas Oct 12, 2014
bf36c6a
Add development installation instructions to README.rst
codelucas Oct 12, 2014
9499164
Make README.rst more readible
codelucas Oct 12, 2014
3c164f2
Make README.rst more readible
codelucas Oct 12, 2014
f5f5b8a
Merge branch 'master' of https://github.com/codelucas/newspaper
codelucas Oct 13, 2014
7fdd861
Merge branch 'master' of https://github.com/codelucas/newspaper
codelucas Oct 13, 2014
0ad9bae
Merge branch 'master' of https://github.com/codelucas/newspaper
codelucas Oct 13, 2014
b9e4c87
Modify install.rst on web site docs
codelucas Oct 13, 2014
3573217
Bugfix in deployment process
codelucas Oct 13, 2014
2ec7f24
Added link to basic demo
iwasrobbed Oct 29, 2014
f5a6c03
split title with _
Nov 17, 2014
d0726cb
Parse was breaking in the method clean_article_html when keep_article…
phoenixwizard Nov 17, 2014
259caca
Merge pull request #83 from iwasrobbed/master
codelucas Nov 17, 2014
fba7583
Merge pull request #88 from phoenixwizard/master
codelucas Nov 18, 2014
493a8a7
Merge pull request #87 from deweydu/master
codelucas Nov 19, 2014
6f5a372
Remove space sandwiching for slash splitter
igor-shevchenko Nov 25, 2014
4d964d0
Fix merge conflicts with adding slash splitting
codelucas Nov 25, 2014
6622556
Merge branch 'slash-splitter' of https://github.com/igor-shevchenko/n…
codelucas Nov 25, 2014
94be062
Merge branch 'igor-shevchenko-slash-splitter'
codelucas Nov 25, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions CHANGES.txt

This file was deleted.

7 changes: 1 addition & 6 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ Lucas Ou-Yang -- lucasyangpersonal@gmail.com

Thanks to the following contributors:
-------------------------------------
- Alex Kessinger - https://github.com/voidfiles
- Oleg Temnov - https://github.com/otemnov
- Matthew Ward - https://github.com/WheresWardy
- Juliano Fischer - https://github.com/julianofischer
- Sandeep Singh - https://github.com/techaddict
- Michael Hood - https://github.com/michaelhood
https://github.com/codelucas/newspaper/graphs/contributors

Newspaper relied on some code of a few other open source projects:
------------------------------------------------------------------
Expand Down
75 changes: 38 additions & 37 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Inspired by `requests`_ for its simplicity and powered by `lxml`_ for its speed:
.. _`tweeted by`: https://twitter.com/kennethreitz/status/419520678862548992
.. _`The Changelog`: http://thechangelog.com/newspaper-delivers-instapaper-style-article-extraction/

Basic Demo: http://newspaper-demo.herokuapp.com

**We support 10+ languages and everything is in unicode!**

.. code-block:: pycon
Expand Down Expand Up @@ -160,7 +162,6 @@ If you are certain that an *entire* news source is in one language, **go ahead a
两年双免0手续0利率 科鲁兹掀背金融轻松购_武汉车市_武汉汽
车网_新浪汽车_新浪网


Documentation
-------------

Expand Down Expand Up @@ -188,67 +189,73 @@ Get it now
Installing newspaper is simple with `pip <http://www.pip-installer.org/>`_.
However, you will run into fixable issues if you are trying to install on ubuntu.

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

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

$ sudo apt-get install python-dev

# Pre-req's for lxml
$ apt-get install libxml2-dev libxslt-dev
- lxml requirements::

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

- For PIL to recognize .jpg images::

# For PIL to recognize .jpg
$ sudo apt-get install libjpeg-dev zlib1g-dev libpng12-dev

$ easy_install lxml # NOT PIP
- Install the distribution via pip::

$ pip install newspaper

$ curl https://raw.github.com/codelucas/newspaper/master/download_corpora.py | python2.7
- Download NLP related corpora::

$ curl https://raw.githubusercontent.com/codelucas/newspaper/master/download_corpora.py | python2.7

**If you are on OSX**, install using the following:

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

# Pre-req's for lxml
$ brew install libxml2 libxslt # or the equiv command in macports
::

$ pip install lxml
$ brew install libxml2 libxslt

# For PIL to recognize .jpg
$ brew install libtiff libjpeg webp little-cms2 # or the equiv with macports
$ brew install libtiff libjpeg webp little-cms2

$ pip install newspaper

$ curl https://raw.github.com/codelucas/newspaper/master/download_corpora.py | python2.7
$ curl https://raw.githubusercontent.com/codelucas/newspaper/master/download_corpora.py | python2.7


**If you are neither using ubuntu nor mac**, install with the following:
**Otherwise**, install with the following:

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

# You will most likely need to install the following libraries via your
# package manager
# for lxml: libxml2-dev libxslt-dev
# for PIL: libjpeg-dev zlib1g-dev libpng12-dev
- PIL: ``libjpeg-dev`` ``zlib1g-dev`` ``libpng12-dev``
- lxml: ``libxml2-dev`` ``libxslt-dev``
- Python Development version: ``python-dev``

$ pip install newspaper
::

$ curl https://raw.github.com/codelucas/newspaper/master/download_corpora.py | python2.7
$ pip install newspaper

$ curl https://raw.githubusercontent.com/codelucas/newspaper/master/download_corpora.py | python2.7

It is also important to note that the line
Development
-----------

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

$ curl https://raw.github.com/codelucas/newspaper/master/download_corpora.py | python2.7
git clone git://github.com/codelucas/newspaper.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::

is not needed unless you need the natural language, ``nlp()``, features like keywords
extraction and summarization.
$ pip install -r requirements.txt
$ python setup.py install

If you are using **ubuntu** and are still running into gcc compile errors when installing lxml, try installing
``libxslt1-dev`` instead of ``libxslt-dev``.
Feel free to give our testing suite a shot::

$ python tests/unit_tests.py

Related Projects
----------------
Expand All @@ -261,12 +268,6 @@ Related Projects
.. _`ruby-readability`: https://github.com/cantino/ruby-readability
.. _`java-boilerpipe`: http://boilerpipe-web.appspot.com/

Todo List
---------

- Add a "follow_robots.txt" option in the config object.
- Bake in the CSSSelect and BeautifulSoup dependencies

.. _`Quickstart guide`: https://newspaper.readthedocs.org/en/latest/
.. _`The Documentation`: http://newspaper.readthedocs.org
.. _`lxml`: http://lxml.de/
Expand Down
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,3 @@ to talk about the future of this library and news extraction in general!
.. _`email & contact me`: mailto:lucasyangpersonal@gmail.com
.. _`python-goose's`: https://github.com/grangier/python-goose
.. _`here`: https://github.com/codelucas/newspaper/blob/master/GOOSE-LICENSE.txt

7 changes: 1 addition & 6 deletions docs/user_guide/contributors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ Lucas Ou-Yang -- http://codelucas.com, lucasyangpersonal@gmail.com

Thanks to the following contributors:
-------------------------------------
- Alex Kessinger - https://github.com/voidfiles
- Oleg Temnov - https://github.com/otemnov
- Matthew Ward - https://github.com/WheresWardy
- Sandeep Singh - https://github.com/techaddict
- Michael Hood - https://github.com/michaelhood
- Juliano Fischer - https://github.com/julianofischer
https://github.com/codelucas/newspaper/graphs/contributors

Newspaper relied on some code of a few other open source projects:
------------------------------------------------------------------
Expand Down
62 changes: 27 additions & 35 deletions docs/user_guide/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,70 +8,58 @@ The first step to using any software package is getting it properly installed.

Distribute & Pip
----------------

Installing newspaper is simple with `pip <http://www.pip-installer.org/>`_.
However, you will run into fixable issues if you are trying to install on ubuntu.

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

**If you are on ubuntu**, install using the following:
- Python development version, needed for Python.h::

::
$ sudo apt-get install python-dev

- lxml requirements::

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

# Pre-req's for lxml
$ apt-get install libxml2-dev libxslt-dev
- For PIL to recognize .jpg images::

# For PIL to recognize .jpg
$ sudo apt-get install libjpeg-dev zlib1g-dev libpng12-dev

$ easy_install lxml # NOT PIP
- Install the distribution via pip::

$ pip install newspaper

$ curl https://raw.github.com/codelucas/newspaper/master/download_corpora.py | python2.7
- Download NLP related corpora::

$ curl https://raw.githubusercontent.com/codelucas/newspaper/master/download_corpora.py | python2.7

**If you are on OSX**, install using the following:

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

# Pre-req's for lxml
$ brew install libxml2 libxslt # or the equiv command in macports
::

$ pip install lxml
$ brew install libxml2 libxslt

# For PIL to recognize .jpg
$ brew install libtiff libjpeg webp little-cms2 # or the equiv with macports
$ brew install libtiff libjpeg webp little-cms2

$ pip install newspaper

$ curl https://raw.github.com/codelucas/newspaper/master/download_corpora.py | python2.7


**If you are neither using ubuntu nor mac**, install with the following:
$ curl https://raw.githubusercontent.com/codelucas/newspaper/master/download_corpora.py | python2.7

::

# You will most likely need to install the following libraries via your
# package manager
# for lxml: libxml2-dev libxslt-dev
# for PIL: libjpeg-dev zlib1g-dev libpng12-dev

$ pip install newspaper

$ curl https://raw.github.com/codelucas/newspaper/master/download_corpora.py | python2.7
**Otherwise**, install with the following:

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

It is also important to note that the line
- PIL: ``libjpeg-dev`` ``zlib1g-dev`` ``libpng12-dev``
- lxml: ``libxml2-dev`` ``libxslt-dev``
- Python Development version: ``python-dev``

::

$ curl https://raw.github.com/codelucas/newspaper/master/download_corpora.py | python2.7


is not needed unless you need the natural language, ``nlp()`` features like keywords extraction and summarization.
$ pip install newspaper

If you are using ubuntu and are still running into gcc compile errors when installing lxml, try installing
``libxslt1-dev`` instead of ``libxslt-dev``.
$ curl https://raw.githubusercontent.com/codelucas/newspaper/master/download_corpora.py | python2.7

Get the Code
------------
Expand All @@ -86,5 +74,9 @@ You can clone the public repository::
Once you have a copy of the source, you can embed it in your Python package,
or install it into your site-packages easily::

$ pip install -r requirements.txt
$ python setup.py install

Feel free to give our testing suite a shot::

$ python tests/unit_tests.py
13 changes: 12 additions & 1 deletion newspaper/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
TITLE_REPLACEMENTS = ReplaceSequence().create(u"&raquo;").append(u"»")
PIPE_SPLITTER = StringSplitter("\\|")
DASH_SPLITTER = StringSplitter(" - ")
UNDERSCORE_SPLITTER = StringSplitter("_")
SLASH_SPLITTER = StringSplitter("/")
ARROWS_SPLITTER = StringSplitter("»")
COLON_SPLITTER = StringSplitter(":")
SPACE_SPLITTER = StringSplitter(' ')
Expand Down Expand Up @@ -182,6 +184,15 @@ def get_title(self, doc):
title_text = self.split_title(title_text, DASH_SPLITTER)
used_delimeter = True

# split title with _
if not used_delimeter and '_' in title_text:
title_text = self.split_title(title_text, UNDERSCORE_SPLITTER)

# split title with /
if not used_delimeter and '/' in title_text:
title_text = self.split_title(title_text, SLASH_SPLITTER)
used_delimeter = True

# split title with »
if not used_delimeter and u'»' in title_text:
title_text = self.split_title(title_text, ARROWS_SPLITTER)
Expand Down Expand Up @@ -832,7 +843,7 @@ def is_table_and_no_para_exist(self, e):
self.parser.remove(p)

subParagraphs2 = self.parser.getElementsByTag(e, tag='p')
if len(subParagraphs2) == 0 and e.tag is not "td":
if len(subParagraphs2) == 0 and e.tag != "td":
return True
return False

Expand Down
1 change: 1 addition & 0 deletions newspaper/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import logging
import lxml.etree
import lxml.html
import lxml.html.clean

from copy import deepcopy

Expand Down
2 changes: 1 addition & 1 deletion newspaper/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
__license__ = 'MIT'
__copyright__ = 'Copyright 2014, Lucas Ou-Yang'

version_info = (0, 0, 7)
version_info = (0, 0, 8)
__version__ = ".".join(map(str, version_info))
Loading