coURLan: Filter, clean, and sample URLs for web crawling
Why coURLan?
"It is important for the crawler to visit 'important' pages first,
so that the fraction of the Web that is visited (and kept up to date)
is more meaningful." (Cho et al. 1998)
"Given that the bandwidth for conducting crawls is neither infinite
nor free, it is becoming essential to crawl the Web in not only a
scalable, but efficient way, if some reasonable measure of quality or
freshness is to be maintained." (Edwards et al. 2001)
This library provides an additional "brain" for web crawling, scraping
and document management. It facilitates web navigation through a set of
filters, enhancing the quality of resulting document collections:
Validate, clean, and normalize URLs, including tracker removal
Save bandwidth by steering clear of spam, unwanted content types, and
low-value pages
Identify pages by language with locale-aware heuristics
Sample URLs by domain and pinpoint pages relevant for link gathering
Store, deduplicate, and schedule URLs with a crawl-ready data store
Use it from Python or on the command line
Wade through the Web and keep the good links. The logo shows a
courlan, also called limpkin.
Installation
This package requires Python 3.10 or higher and is tested on Linux, macOS
and Windows systems.
courlan is available on PyPI and installs with pip:
pip install courlan
pip install git+https://github.com/adbar/courlan.git # latest available code
Use extract_links() for general-purpose link extraction. For
crawl-aware extraction with robots.txt rules and link prioritization,
use filter_links() instead — it returns two lists: regular links and
priority (navigation) links.
For frontier management utilities (is_external, is_navigation_page,
is_not_crawlable, …) see the
crawling guide.
Python helpers
>>> from courlan import clean_url
>>> clean_url('HTTPS://WWW.DWDS.DE:443/')
'https://www.dwds.de'
For normalize_url, validate_url, get_base_url, get_hostinfo,
and other utilities see the
cleaning guide.
UrlStore class
The UrlStore class allows for storing and retrieving domain-classified
URLs, where a URL like https://example.org/path/testpage is stored as
the path /path/testpage within the domain https://example.org:
>>> from courlan import UrlStore
>>> store = UrlStore()
>>> store.add_urls(['https://example.org/page1', 'https://example.org/page2'])
>>> store.get_url('https://example.org')
'https://example.org/page1'
>>> store.find_unvisited_urls('https://example.org')
['https://example.org/page2']
See the UrlStore guide for all methods,
options, persistence, and crawl scheduling.
Settings
Language filtering reads language codes in URL paths for any language,
and in subdomains with strict=True. Language names in lang= query
values are mapped for English and German by default. See the
settings reference
for how to review and override filtering rules.
Author
Initially launched to create text databases for research purposes
at the Berlin-Brandenburg Academy of Sciences (DWDS and ZDL units),
this package continues to be maintained but its future development
depends on community support.
If you value this software or depend on it for your product, consider
sponsoring it and contributing to its codebase. Your support
on GitHub or ko-fi.com
will help maintain and enhance this package.
Visit the Contributing page
for more information.
Reach out via the software repository or the contact
page for inquiries, collaborations, or
feedback.
For more on Courlan's software ecosystem see this
graphic.
These Python libraries perform URL handling and normalization but do not
provide language-aware filtering, content heuristics, crawl scheduling,
or a domain-classified URL store:
Cho, J., Garcia-Molina, H., & Page, L. (1998). Efficient crawling
through URL ordering. Computer networks and ISDN systems, 30(1-7),
161–172.
Edwards, J., McCurley, K. S., and Tomlin, J. A. (2001). "An
adaptive model for optimizing performance of an incremental web
crawler". In Proceedings of the 10th international conference on
World Wide Web - WWW'01, pp. 106–113.
Works well with
Use together with courlan: extensions, drivers, servers and companion tools.
trafilaturaPythie’s Index: 88Python & Command-line tool to gather text and metadata on the Web: Crawling, scraping, extraction, output as CSV, JSON, HTML, MD, TXT, XML.17.4M downloads/mo