Skip to main content

Python ctypes bindings for reliq

Project description

reliq-python

A python module for reliq library.

Requirements

Installation

pip install reliq

Import

from reliq import reliq

Usage

from reliq import reliq, ReliqError

html = ""
with open('index.html','r') as f:
    html = f.read()

rq = reliq(html) #parse html
expr = reliq.expr(r"""
    div .user; {
        a href; {
            .name * l@[0] | "%i"
            .link * l@[0] | "%(href)v"
        },
        .score.u span .score,
        .info dl; {
            .key dt | "%i",
            .value dd | "%i"
        },
        .achievements.a li class=b>"achievement-" | "%i\n"
    }
""") #expressions can be compiled

users = []
links = []
images = []

#filter()
#   returns object holding list of results such object
#   behaves like an array, but can be converted to array with
#       self() - objects with lvl() 0
#       children() - objects with lvl() 1
#       descendants() - objects with lvl > 0
#       full() - same as indexing filter(), all objects

for i in rq.filter(r'table; tr').self()[:-2]:
    #"i"
    #   It has a set of functions for getting its properties:
    #       tag()           tag name
    #       insides()       string containing contents inside tag
    #       desc_count()   count of descendants
    #       lvl()           level in html structure
    #       attribsl()      number of attributes
    #       attribs()       returns dictionary of attributes

    if i.child_count() < 3 and i[0].tag() == "div":
        continue

    #objects can be accessed as an array which is the same
    #as array returned by descendants() method
    link = i[5].attribs()['href']
    if re.match('^https://$',href):
        links.append(link)
        continue

    #search() returns str, in this case expression is already compiled
    user = json.loads(i.search(expr))
    users.append(user)

#reliq objects have __str__ method
#get_data() returns data from which the html structure has been compiled

#if the second argument of filter() is True the returned
#object will use independent data, allowing garbage collector
#to free the previous unused data

#fsearch()
#   executes expression at parsing saving memory, and because
#   of that it supports only chain expressions i.e use of
#   grouping brackets and separating commas will throw an exception
for i in reliq.fsearch(r'ul; img src | "%(src)v\n"',html).split('\n')[:-1]:
    images.append(i)

try: #handle errors
    reliq.fsearch('p / /','<p></p>')
except ReliqError:
    print("error")

Projects using reliq

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

reliq-0.0.29.tar.gz (17.7 kB view details)

Uploaded Source

Built Distributions

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

reliq-0.0.29-cp312-cp312-win_amd64.whl (146.9 kB view details)

Uploaded CPython 3.12Windows x86-64

reliq-0.0.29-cp312-cp312-win32.whl (146.9 kB view details)

Uploaded CPython 3.12Windows x86

reliq-0.0.29-cp312-cp312-manylinux2014_x86_64.whl (117.8 kB view details)

Uploaded CPython 3.12

reliq-0.0.29-cp312-cp312-macosx_14_0_arm64.whl (87.8 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

reliq-0.0.29-cp312-cp312-macosx_13_0_arm64.whl (91.7 kB view details)

Uploaded CPython 3.12macOS 13.0+ ARM64

reliq-0.0.29-cp311-cp311-manylinux2014_armv7l.whl (93.3 kB view details)

Uploaded CPython 3.11

reliq-0.0.29-cp311-cp311-manylinux2014_aarch64.whl (114.1 kB view details)

Uploaded CPython 3.11

reliq-0.0.29-cp310-cp310-win_amd64.whl (146.9 kB view details)

Uploaded CPython 3.10Windows x86-64

reliq-0.0.29-cp310-cp310-manylinux2014_armv7l.whl (93.3 kB view details)

Uploaded CPython 3.10

reliq-0.0.29-cp310-cp310-manylinux2014_aarch64.whl (114.1 kB view details)

Uploaded CPython 3.10

reliq-0.0.29-cp310-cp310-macosx_14_0_arm64.whl (87.7 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

reliq-0.0.29-cp310-cp310-macosx_13_0_arm64.whl (91.7 kB view details)

Uploaded CPython 3.10macOS 13.0+ ARM64

File details

Details for the file reliq-0.0.29.tar.gz.

File metadata

  • Download URL: reliq-0.0.29.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for reliq-0.0.29.tar.gz
Algorithm Hash digest
SHA256 cd3bfcd208f12e26721e2fff076039a51a5298e7263bbaee167f902dcda6f2f2
MD5 ef8e5a8755096ab754abd96bfba06d6e
BLAKE2b-256 a5b3cd83527bee6324c979897e802b807628553934b4b80d1a08b79b6b72e6d4

See more details on using hashes here.

File details

Details for the file reliq-0.0.29-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: reliq-0.0.29-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 146.9 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for reliq-0.0.29-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5b84e477c870dcb233c1bfcb814f19737eebb8a546dc6cffc1bcef96460368d6
MD5 6c892efe251eaffaf21b367e694d75af
BLAKE2b-256 faeb186f62359938a66863ec7192e1d27091d9080c0beff93df6894f3d5daaff

See more details on using hashes here.

File details

Details for the file reliq-0.0.29-cp312-cp312-win32.whl.

File metadata

  • Download URL: reliq-0.0.29-cp312-cp312-win32.whl
  • Upload date:
  • Size: 146.9 kB
  • Tags: CPython 3.12, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for reliq-0.0.29-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 a482b26427325b4c930f383b8aeedd845f7d3ff64d117b27a743196de3dbe3b7
MD5 2a576b51c7ecade498ba8431e0c65e4f
BLAKE2b-256 33e54ffaa98bef626d54db81646fcf1b2eaa1ba79d0b12628a63b728f0cddaaf

See more details on using hashes here.

File details

Details for the file reliq-0.0.29-cp312-cp312-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for reliq-0.0.29-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 79aea1a78e21bc80ad265f673ad880e6d77de2232ac8cdcbaa770e21756b2547
MD5 4946106cada1bb546309925e8abf9a2b
BLAKE2b-256 3047813ff3ccbb2a8351e53c2301a2cbc3941d41624cb592b73173806c53ab9f

See more details on using hashes here.

File details

Details for the file reliq-0.0.29-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for reliq-0.0.29-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 3b5edf63a26da418b8d556fa721e64dc8fe2eaec5c770538d6e46eaf7ed3d0cf
MD5 995c492bff1b5ee181e9938c62411a73
BLAKE2b-256 b5d9bd9c34006ee74d05a2d64caaf50b091469ffccf0040f68bc887da918da3f

See more details on using hashes here.

File details

Details for the file reliq-0.0.29-cp312-cp312-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for reliq-0.0.29-cp312-cp312-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 b5b30601375f3dcd3f33c04d743ce9cbd9d3f81bcb752d3c65e21216f91af7d2
MD5 b35badd26cb5e54363d582ec4fccbcb9
BLAKE2b-256 5cd5edf5adb44327cc387263b3e4a4bee23354ae8506e9aac06471adc6d7d5a0

See more details on using hashes here.

File details

Details for the file reliq-0.0.29-cp311-cp311-manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for reliq-0.0.29-cp311-cp311-manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 abf3895a9d15d681226f5e32f8bd677ce6289ab7c1322d3045dfc46df1d9c9b8
MD5 32b4ba877cbc7cc7110017caee7be618
BLAKE2b-256 03ab35b8b151cd299e8aa0bf0bf5cd0879ea4de995a06f26bf831582d3b235cb

See more details on using hashes here.

File details

Details for the file reliq-0.0.29-cp311-cp311-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for reliq-0.0.29-cp311-cp311-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 64a5aa616270d2b9363c8baf1f4625c16ddb5a9d870a9c1cf45a8d525107e0cf
MD5 7e962993c5135701c3b8b31e9f7251f7
BLAKE2b-256 9edc131bc25d174e6c95b32f25ff20a48c47dc8f4248f938057ca79e8cb412b8

See more details on using hashes here.

File details

Details for the file reliq-0.0.29-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: reliq-0.0.29-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 146.9 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for reliq-0.0.29-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f61cdad15f9a8cd9576b72207c9687c63f23ab2c7ce4943d3ce722ca957d265a
MD5 71d2edfd830381ae54ffb45bf1e0dc40
BLAKE2b-256 564757b752f6f9d8eac93ecadd0bb19a7896e4884d2008f609bdbb8f0fff7fb0

See more details on using hashes here.

File details

Details for the file reliq-0.0.29-cp310-cp310-manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for reliq-0.0.29-cp310-cp310-manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 01f02bc61e2fd75d6f59a8a46c1e2c2a2ea93cdfcab836db98cd090d09981840
MD5 2a1eae8d57ea83c6fe1416edca98f215
BLAKE2b-256 fa76750d6f98b0dd1078a18552ae4263b92ab3719bc36c9d8f7bf3cde8072676

See more details on using hashes here.

File details

Details for the file reliq-0.0.29-cp310-cp310-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for reliq-0.0.29-cp310-cp310-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 78567d8c66bebc235e3e9b728a08a33744f01a1f241f4b75744f2e196425b284
MD5 46bed1624ac00a09bd42bd0f18f35fc9
BLAKE2b-256 b051690a920e228bb14c57bddab1549d39471a0e0bb7e6539b190e0255820bdc

See more details on using hashes here.

File details

Details for the file reliq-0.0.29-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for reliq-0.0.29-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 15a5165abbfb8a3cf403476ae7c2630409f769a804b38ade9b2a5b133a98c787
MD5 31ebc350ffb820306dee9af9030eb2b9
BLAKE2b-256 b1fef40f26f2d11c1e9dae85bd9428461879cdca327c86819a8f8fba9836bbbb

See more details on using hashes here.

File details

Details for the file reliq-0.0.29-cp310-cp310-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for reliq-0.0.29-cp310-cp310-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 1588977674c68063f1f092d1d6de517dd265337feb06f2d4e3a9eee0af4e4ef9
MD5 a687423f15e00f5a7c4db6b4430363bc
BLAKE2b-256 bae2858bdaefaa26c6b3e615ca16550b4ef0bddfa40c071bd136c6cb965318e9

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