Skip to main content

codecov Python Versions PyPI - Version GitHub

Articulo

Tiny library for extraction articles from html.
It can extract the content of an article, both in text and HTML, and it's title.

Usage

Basic usage

This library is designed to be as simple as possible.
To start using it just import it and instantiate with link you want to parse as a parameter.

Also the library designed to work in lazy manner.
So, until you make a request for some property, it does not send any requests.

from articulo import Articulo

# Step 1: initializing Articulo instance
article = Articulo('https://info.cern.ch/')

# Step 2: requesting article properties. All properties resolve lazily.
print(article.title) # article title as a string
print(article.text) # article content as a string
print(article.markup) # article content as an html markup string
print(article.icon) # link to article icon
print(article.description) # article meta description
print(article.preview) # link to article meta preview image
print(article.keywords) # article meta keywords list

Verbose mode

In case you want to see the whole procees just provide parameter verbose=True to the instance. It can be helpful for debugging.

from articulo import Articulo

# Initializing Articulo instance with verbose mode
article = Articulo('https://info.cern.ch/', verbose=True)

Controlling information loss coefficient

The whole idea of parsing article content is to define the part of the document that has the highest information density. To find that part there is the so-called information loss coefficient. This coefficient determines the decrease in the text density of the document during parsing.

The default value is 0.7 which stands for 70% information density decrease. In most cases, this works fine.
Nevertheless, you can change it in case you have insufficient parsing results. Just provide theshold parameter to the articulo instance, it might help.

from articulo import Articulo

# Initializing Articulo instance with information loss coefficient of 30%
article = Articulo('https://info.cern.ch/', threshold=0.3)

Providing headers

In some cases you need to provide additional headers to get an article html from url.
For that case you can provide headers with http_headers parameter when you create new instance of articulo.

from articulo import Articulo

# Initializing Articulo instance with custom user agent
headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36' }
article = Articulo('https://info.cern.ch/', http_headers=headers)

Providing custom charset

Articulo uses requests library to get html from url. This library tries to guess the encoding of the response based on the HTTP headers. Although it works fine most of the time, in some cases this might not work as expected, and you'll get a mess instead of text. For that case you can provide custom charset with def_charset parameter when you create new instance of articulo.

from articulo import Articulo

# Initializing Articulo instance with cp1251 charset
article = Articulo('https://info.cern.ch/', def_charset='cp1251')

Metadata

Release files for articulo 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for articulo 0.5.1
File Size Uploaded
articulo-0.5.1.tar.gz 20.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for articulo 0.5.1
File Interpreter ABI Platform
articulo-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 41.1 kB

Release files / articulo-0.5.1.tar.gz

Download URL articulo-0.5.1.tar.gz
Size 20.4 kB
Tags Source
SHA-256 checksum
How to use checksums
51446fe65a372f612740806fc83e7d2c365181e6f3e686f890effe9e4c99858e
BLAKE2b-256 checksum
How to use checksums
f112f37257b7602d29ecb955ac1f8145f037faa99a2cb9f39726768a8c74c552
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.10.9 Darwin/24.1.0

Release files / articulo-0.5.1-py3-none-any.whl

Download URL articulo-0.5.1-py3-none-any.whl
Size 20.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
081ed332f0748e2c7cd66876e69d4c89af59e020d41c65127d0099a2c9c5abdc
BLAKE2b-256 checksum
How to use checksums
ea315abd2c76662fe470b6d15d3741e0648fe52d0bc985f99afe883da37a67d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.10.9 Darwin/24.1.0

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page