Skip to main content

Hyper-Text Query Language for querying HTML, XML and text documents

Project description

HTQL - the Hyper-Text Query Language

The Hyper-Text Query Language (HTQL) is a language for the querying and transformation of HTML, XML and plain text documents. HTQL is developed in C++ with fast and efficient data extraction algorithms. HTQL can be used to:

  • Extract data from HTML pages
  • Retrieve HTML page through HTTP protocol
  • Modify HTML pages

Python Installation

Run:

pip install htql

Python Examples

A simple example to extract url and text from links.

import htql

page="<a href=a.html>1</a><a href=b.html>2</a><a href=c.html>3</a>"
query="<a>:href,tx"

for url, text in htql.query(page, query):
    print(url, text)

Another example to parse state and zip from US address using HTQL regular expression:

import htql
address = '88-21 64th st , Rego Park , New York 11374'
states=['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut',
    'Delaware', 'District Of Columbia', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana',
    'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan',
    'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire',
    'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma',
    'Oregon', 'PALAU', 'Pennsylvania', 'PUERTO RICO', 'Rhode Island', 'South Carolina', 'South Dakota',
    'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin',
    'Wyoming']

a=htql.RegEx()
a.setNameSet('states', states)

state_zip1=a.reSearchStr(address, r"&[s:states][,\s]+\d{5}", case=False)[0]
# state_zip1 = 'New York 11374'

state_zip2=a.reSearchList(address.split(), r"&[ws:states]<,>?<\d{5}>", case=False)[0]
# state_zip2 = ['New', 'York', '11374']

Manuals

Home

http://htql.net

Citation

  • Liangyou Chen. Ad Hoc Integration and Querying of Heterogeneous Online Distributed Databases. 2004. Ph.D. Dissertation, Department of Computer Science & Engineering, Mississippi State University.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

htql-1.0.2.tar.gz (300.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

htql-1.0.2-cp313-cp313-win_amd64.whl (355.2 kB view details)

Uploaded CPython 3.13Windows x86-64

File details

Details for the file htql-1.0.2.tar.gz.

File metadata

  • Download URL: htql-1.0.2.tar.gz
  • Upload date:
  • Size: 300.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for htql-1.0.2.tar.gz
Algorithm Hash digest
SHA256 b411bbc5e3e517d0a9b4d135d3660971e20f5ef09ba15d2f9f562bb06a980c71
MD5 113663fe870cc54ff05eca50917c62c0
BLAKE2b-256 c2a94f5a86105ad27d83ab564d59c73575122ceed79984d4946c4896ea99df0c

See more details on using hashes here.

File details

Details for the file htql-1.0.2-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: htql-1.0.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 355.2 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for htql-1.0.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 18e34d228e0d7538c2e7992379673ad6b9b7876a28b116399e46a6242b0ea17f
MD5 2b1e95fdd4d4ca281034d18b6f225413
BLAKE2b-256 64f399bf282820bfe871ce035664c2d4e07c020ccf618ee81f730ce67e99f3cd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page