Skip to content

object has no attribute clean Error when using parse method #90

Description

@rohiniragunathan

I am getting an error below, but it was previously working, and works in another program where I use the parse method. Is there something I may be doing wrong?

When I call it in the shell, there is no error.

 >>> article_cleaner = lxml.html.clean.Cleaner()

My code:

from newspaper import Article

article = Article(url="http://sports.nationalpost.com/2014/11/22/toronto-raptors-overcome-slow-start-to-hand-cleveland-cavaliers-fourth-straight-loss/",  keep_article_html=True)
article.download()
article.parse()
print article.title 
print article.authors 
print article.text
print article.published_date
print article.article_html

Error:

Traceback (most recent call last):
  File "newspaper_trial.py", line 5, in <module>
    article.parse()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/newspaper/article.py", line 221, in parse
    self.top_node)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/newspaper/outputformatters.py", line 47, in get_formatted
    html = self.convert_to_html()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/newspaper/outputformatters.py", line 68, in convert_to_html
    cleaned_node = self.parser.clean_article_html(self.get_top_node())
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/newspaper/parsers.py", line 62, in clean_article_html
    article_cleaner = lxml.html.clean.Cleaner()
AttributeError: 'module' object has no attribute 'clean'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions