Giter Club home page Giter Club logo

python-ftr's Introduction

python-ftr

FTR is a partial (re-)implementation of the Five-Filters extractor in Python.

It cleans up HTML web pages and extract their content and metadata for a more comfortable reading experience (or whatever you need it for). It uses a centralized and mutualized repository of configuration files to parse websites at the most precise level possible, and fallbacks to the well-known readability automatic extractor if no configuration is found.

A notable difference is that this python implementation will fetch the website configuration from a centralized repository on the internet on the fly if no configuration is found locally.

Full documentation is available.

Differences with the FiveFilters PHP implementation

python-ftr :

  • has only one parser library (lxml) for now. The html5lib has not been ported yet.
  • does not convert date strings to datetime objects. I felt this more flexible to handle them at the upper level, giving access to custom datetime parsers. This is likely to change if I implement passing a custom parsing function to the extractor.
  • uses readability-lxml for cleaning after non-automatic body extraction. Even if it's a port of Arc90 readability.js like the PHP Readability port used by Five Filters, it could eventually produce different results from it given the way they compute weight on contents (I didn't compare them code-wise).
  • does not fallback to automatic parsing when no site config is available, but it does partially when a config is found and fails. As python-ftr was created to be included in a complex parsing chain, we had no need for an automatic parsing when there is no config for current site. See below for details.
  • has no fingerprints support. This feature looked unfinished or at least not enough documented for me to understand it in the original code.
  • does not use the global five-filters config file at all. The .txt looked unmaintained, and generic fallbacks can still be implemented outside of this module : you can provide your own global config via an argument when using the API.

Automatic extraction

If you need fully-automatic parsing in no-config-found situations — which are easily detectable because process() and the low-level API raise SiteConfigNotFound — just use readability-lxml, breadability, python-goose, soup-strainer or whatever fits you.

In the case of an existing config but parsing failing for whatever reason, we still honor autodetect_on_failure and try to extract at least a title and a body via readability-lxml.

This is not as featureful as the PHP implementation which tries to extract date, language and authors via other ways, but still better than nothing.

When automatic extraction is used, the ContentExtractor instance will have a .failures attributes, listing exactly which non-automatic extraction(s) failed.

In the case where a config is found but it has no site or body directive (eg. automatic extraction should be explicitely used), the .failures attributes will not be set if automatic extraction worked.

TODO

See issues wishlist for a dynamic todo list.

License

GNU Affero GPL version 3.

python-ftr's People

Contributors

karmak23 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

koppa

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.