1- # Trafilatura: Discover and Extract Text Data on the Web
1+ # Trafilatura: Discover Web Content, Extract Text and Metadata
22
33<br />
44
1313[ ![ Downloads] ( https://static.pepy.tech/badge/trafilatura/month )] ( https://pepy.tech/project/trafilatura )
1414[ ![ Reference DOI: 10.18653/v1/2021.acl-demo.15] ( https://img.shields.io/badge/DOI-10.18653%2Fv1%2F2021.acl--demo.15-blue )] ( https://aclanthology.org/2021.acl-demo.15/ )
1515
16- <br />
17-
18- <img alt =" Demo as GIF image " src =" https://raw.githubusercontent.com/adbar/trafilatura/master/docs/trafilatura-demo.gif " align =" center " width =" 80% " />
1916
20- <br />
17+ ``` python
18+ >> > from trafilatura import fetch_url, extract
19+ >> > downloaded = fetch_url(" https://github.blog/2019-03-29-leader-spotlight-erin-spiceland/" )
20+ >> > extract(downloaded)
21+ ' Erin Spiceland is a software engineer and ...'
22+ >> > extract(downloaded, output_format = " json" , with_metadata = True )
23+ ' {"title": "Leader spotlight: Erin Spiceland", "author": "Jessica Rudder", "text": "Erin Spiceland is a software engineer and ..."}'
24+ ```
2125
2226
2327## Introduction
2428
25- Trafilatura is a cutting-edge ** Python package and command-line tool**
26- designed to ** gather text on the Web and simplify the process of turning
27- raw HTML into structured, meaningful data** . It includes all necessary
29+ Trafilatura is a comprehensive ** Python package and command-line tool**
30+ designed to ** gather text from the Web and turn raw HTML into structured,
31+ meaningful data** . It includes all necessary
2832discovery and text processing components to perform ** web crawling,
2933downloads, scraping, and extraction** of main texts, metadata and
3034comments. It aims at staying ** handy and modular** : no database is
3135required, the output can be converted to commonly used formats.
3236
33- Going from HTML bulk to essential parts can alleviate many problems
34- related to text quality, by ** focusing on the actual content** ,
35- ** avoiding the noise** caused by recurring elements like headers and footers
36- and by ** making sense of the data and metadata** with selected information.
37+ Going from raw HTML to essential parts, it ** focuses on the actual
38+ content** , ** avoids noise** caused by recurring elements (headers,
39+ footers, boilerplate), and ** makes sense of the data and metadata** .
3740The extractor strikes a balance between limiting noise (precision) and
3841including all valid parts (recall). It is ** robust and reasonably fast** .
3942
4043Trafilatura is [ widely used] ( https://trafilatura.readthedocs.io/en/latest/used-by.html )
41- and integrated into [ thousands of projects] ( https://github.com/adbar/trafilatura/network/dependents )
42- by companies like HuggingFace, IBM, and Microsoft Research as well as institutions like
43- the Allen Institute, Stanford, the Tokyo Institute of Technology, and
44- the University of Munich.
44+ across [ thousands of projects] ( https://github.com/adbar/trafilatura/network/dependents ) ,
45+ including by HuggingFace, IBM, Microsoft Research, NVIDIA, the Allen Institute for AI, Stanford, and the Internet Archive.
4546
4647
4748### Features
4849
4950- Advanced web crawling and text discovery:
50- - Support for sitemaps (TXT, XML) and feeds (ATOM, JSON, RSS)
51- - Smart crawling and URL management (filtering and deduplication)
51+ - Support for sitemaps (TXT, XML) and feeds (ATOM, JSON, RSS)
52+ - Smart crawling and URL management (filtering and deduplication)
5253
5354- Parallel processing of online and offline input:
54- - Live URLs, efficient and polite processing of download queues
55- - Previously downloaded HTML files and parsed HTML trees
55+ - Live URLs, efficient and polite processing of download queues
56+ - Previously downloaded HTML files and parsed HTML trees
5657
5758- Robust and configurable extraction of key elements:
58- - Main text (common patterns and generic algorithms like jusText and readability)
59- - Metadata (title, author, date, site name, categories and tags)
60- - Formatting and structure: paragraphs, titles, lists, quotes, code, line breaks, in-line text formatting
61- - Optional elements: comments, links, images, tables
59+ - Main text (own rule-based extractor with jusText and readability-lxml as fallbacks)
60+ - Metadata (title, author, date, site name, categories and tags)
61+ - Formatting and structure: paragraphs, titles, lists, quotes, code, line breaks, in-line text formatting
62+ - Optional elements: comments, links, images, tables
63+ - Optional add-ons: language detection, speed optimizations
6264
6365- Multiple output formats:
64- - TXT and Markdown
65- - CSV
66- - JSON
67- - HTML, XML and [ XML-TEI] ( https://tei-c.org/ )
66+ - TXT and Markdown
67+ - CSV
68+ - JSON
69+ - HTML, XML and [ XML-TEI] ( https://tei-c.org/ )
6870
69- - Optional add-ons:
70- - Language detection on extracted content
71- - Speed optimizations
7271
73- - Actively maintained with support from the open-source community:
74- - Regular updates, feature additions, and optimizations
75- - Comprehensive documentation
76-
77-
78- ### Evaluation and alternatives
72+ ### Evaluation
7973
8074Trafilatura consistently outperforms other open-source libraries in text
81- extraction benchmarks, showcasing its efficiency and accuracy in
82- extracting web content. The extractor tries to strike a balance between
83- limiting noise and including all valid parts.
84-
85- For more information see the [ benchmark section] ( https://trafilatura.readthedocs.io/en/latest/evaluation.html )
75+ extraction benchmarks. For more information see the
76+ [ benchmark section] ( https://trafilatura.readthedocs.io/en/latest/evaluation.html )
8677and the [ evaluation readme] ( https://github.com/adbar/trafilatura/blob/master/tests/README.rst )
8778to run the evaluation with the latest data and packages.
8879
8980
90- #### Other evaluations:
81+ #### Other evaluations
9182
9283- Most efficient open-source library in * ScrapingHub* 's [ article extraction benchmark] ( https://github.com/scrapinghub/article-extraction-benchmark )
9384- Best overall tool according to [ Bien choisir son outil d'extraction de contenu à partir du Web] ( https://hal.archives-ouvertes.fr/hal-02768510v3/document )
@@ -96,7 +87,7 @@ to run the evaluation with the latest data and packages.
9687 (Bevendorff et al. 2023)
9788
9889
99- ## Usage and documentation
90+ ## Documentation
10091
10192[ Getting started with Trafilatura] ( https://trafilatura.readthedocs.io/en/latest/quickstart.html )
10293is straightforward. For more information and detailed guides, visit
@@ -108,12 +99,10 @@ is straightforward. For more information and detailed guides, visit
10899 [ With Python] ( https://trafilatura.readthedocs.io/en/latest/usage-python.html ) ,
109100 [ With R] ( https://trafilatura.readthedocs.io/en/latest/usage-r.html )
110101- [ Core Python functions] ( https://trafilatura.readthedocs.io/en/latest/corefunctions.html )
111- - Interactive Python Notebook: [ Trafilatura Overview] ( docs/Trafilatura_Overview.ipynb )
102+ - Interactive Python Notebook: [ Trafilatura Overview] ( docs/Trafilatura_Overview.ipynb ) (in the repository)
112103- [ Tutorials and use cases] ( https://trafilatura.readthedocs.io/en/latest/tutorials.html )
113104
114- Youtube playlist with video tutorials in several languages:
115-
116- - [ Web scraping tutorials and how-tos] ( https://www.youtube.com/watch?v=8GkiOM17t0Q&list=PL-pKWbySIRGMgxXQOtGIz1-nbfYLvqrci )
105+ See the [ video tutorials playlist] ( https://www.youtube.com/watch?v=8GkiOM17t0Q&list=PL-pKWbySIRGMgxXQOtGIz1-nbfYLvqrci ) (multiple languages).
117106
118107
119108## License
@@ -123,7 +112,7 @@ This package is distributed under the [Apache 2.0 license](https://www.apache.or
123112Versions prior to v1.8.0 are under GPLv3+ license.
124113
125114
126- ### Contributing
115+ ## Contributing
127116
128117Contributions of all kinds are welcome. Visit the [ Contributing
129118page] ( https://github.com/adbar/trafilatura/blob/master/CONTRIBUTING.md )
@@ -135,18 +124,21 @@ Many thanks to the
135124who extended the docs or submitted bug reports, features and bugfixes!
136125
137126
127+ ## Support
128+
129+ ** If you value this software or depend on it for your product, consider
130+ sponsoring it and contributing to its codebase.** Your support
131+ [ on GitHub] ( https://github.com/sponsors/adbar ) or [ ko-fi.com] ( https://ko-fi.com/adbarbaresi )
132+ will help maintain and enhance this package.
133+
134+
138135## Context
139136
140137This work started as a PhD project at the crossroads of linguistics and
141- NLP, this expertise has been instrumental in shaping Trafilatura over
138+ NLP. This expertise has been instrumental in shaping Trafilatura over
142139the years. Initially launched to create text databases for research purposes
143140at the Berlin-Brandenburg Academy of Sciences (DWDS and ZDL units),
144- this package continues to be maintained but its future depends on community support.
145-
146- ** If you value this software or depend on it for your product, consider
147- sponsoring it and contributing to its codebase** . Your support
148- [ on GitHub] ( https://github.com/sponsors/adbar ) or [ ko-fi.com] ( https://ko-fi.com/adbarbaresi )
149- will help maintain and enhance this popular package.
141+ this package continues to be maintained and its future depends on community support.
150142
151143* Trafilatura* is an Italian word for [ wire
152144drawing] ( https://en.wikipedia.org/wiki/Wire_drawing ) symbolizing the
@@ -155,7 +147,7 @@ are formed.
155147
156148### Author
157149
158- Reach out via ia the software repository or the [ contact
150+ Reach out via the software repository or the [ contact
159151page] ( https://adrien.barbaresi.eu/ ) for inquiries, collaborations, or
160152feedback. See also social networks for the latest updates.
161153
@@ -198,10 +190,8 @@ acquisition. Here is how to cite it:
198190Jointly developed plugins and additional packages also contribute to the
199191field of web data extraction and analysis:
200192
201- <img alt =" Software ecosystem " src =" https://raw.githubusercontent.com/adbar/htmldate/master/docs/software-ecosystem.png " align =" center " width =" 65% " />
193+ <img alt =" Diagram of trafilatura and related packages (htmldate, courlan, jusText) " src =" https://raw.githubusercontent.com/adbar/htmldate/master/docs/software-ecosystem.png " align =" center " width =" 65% " />
202194
203195Corresponding posts can be found on [ Bits of
204196Language] ( https://adrien.barbaresi.eu/blog/tag/trafilatura.html ) .
205197
206- Impressive, you have reached the end of the page: Thank you for your
207- interest!
0 commit comments