Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/parsers #39

Merged
merged 3 commits into from Apr 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
@@ -1,10 +1,11 @@
# Goose3

### ***Current Master Branch***
### Version 3.1.0
* Changed configuration to ***not*** pull images by default [see issue #31](https://github.com/goose3/goose3/issues/31)
* Update `get_encodings_from_content` to return a string and remove trailing spaces [#35](https://github.com/goose3/goose3/pull/35)
* Remove infinite recursion on parser selection [#39](https://github.com/goose3/goose3/pull/39)
* Document video and image classes
* Re-add remaining image tests
* Update `get_encodings_from_content` to return a string and remove trailing spaces

### Version 3.0.9
* Add `soup` as a parser option to use `lxml.html.soupparser` [#27](https://github.com/goose3/goose3/issues/27)
Expand Down
25 changes: 15 additions & 10 deletions goose3/__init__.py
Expand Up @@ -121,15 +121,20 @@ def shutdown_network(self):
self.fetcher = None

def __crawl(self, crawl_candidate):
''' wrap the crawling functionality '''
def crawler_wrapper(parser, parsers_lst, crawl_candidate):
try:
crawler = Crawler(self.config, self.fetcher)
article = crawler.crawl(crawl_candidate)
except (UnicodeDecodeError, ValueError) as ex:
if parsers_lst:
parser = parsers_lst.pop(0) # remove it also!
return crawler_wrapper(parser, parsers_lst, crawl_candidate)
else:
raise ex
return article

''' use the wrapper '''
parsers = list(self.config.available_parsers)
parsers.remove(self.config.parser_class)
try:
crawler = Crawler(self.config, self.fetcher)
article = crawler.crawl(crawl_candidate)
except (UnicodeDecodeError, ValueError) as ex:
if parsers:
self.config.parser_class = parsers[0]
return self.__crawl(crawl_candidate)
else:
raise ex
return article
return crawler_wrapper(self.config.parser_class, parsers, crawl_candidate)
2 changes: 1 addition & 1 deletion goose3/article.py
Expand Up @@ -243,7 +243,7 @@ def infos(self):
''' dict: The summation of all data available about the extracted article

Note:
Not settable '''
Read only '''
data = {
"meta": {
"description": self.meta_description,
Expand Down
2 changes: 1 addition & 1 deletion goose3/version.py
Expand Up @@ -21,5 +21,5 @@
limitations under the License.
"""

version_info = (3, 0, 9) # pylint: disable=C0103
version_info = (3, 1, 0) # pylint: disable=C0103
__version__ = ".".join([str(x) for x in version_info])