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
Release history Release notifications | RSS feed
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.26.tar.gz
(17.6 kB
view details)
Built Distributions
File details
Details for the file reliq-0.0.26.tar.gz
.
File metadata
- Download URL: reliq-0.0.26.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df445473a1ef1ba832b9df8b2bd357a7cffd52db3859b4141856bba71d47eab4 |
|
MD5 | 9538b8df2437b0c00481f0e79ff326a1 |
|
BLAKE2b-256 | d8cf8757d7e1ebd0f9645c07e67850d5ac7301cfd62de8618a3c653b8b7f0000 |
File details
Details for the file reliq-0.0.26-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: reliq-0.0.26-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 143.6 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66c5e38d7023b2773ce043565c94161a456d9af3c9ad41349b9a10784ad95d27 |
|
MD5 | 9e0dc2fa839ffbf8a291d49bea8812cc |
|
BLAKE2b-256 | 94543b60f0da317467cafa12dee15029d248907608f8137eff5e1422c5359242 |
File details
Details for the file reliq-0.0.26-cp312-cp312-manylinux2014_x86_64.whl
.
File metadata
- Download URL: reliq-0.0.26-cp312-cp312-manylinux2014_x86_64.whl
- Upload date:
- Size: 114.2 kB
- Tags: CPython 3.12
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9963fec09cdd91765846a13bc20993d68c07be5c91ddac9559c436ea2860d5c |
|
MD5 | 7010c8d347874d98a6cd03fef78fa15a |
|
BLAKE2b-256 | 8abafec348465298bd2258d1525ab590beb1835687e190e6ea29bc70553b34dc |
File details
Details for the file reliq-0.0.26-cp312-cp312-macosx_13_0_arm64.whl
.
File metadata
- Download URL: reliq-0.0.26-cp312-cp312-macosx_13_0_arm64.whl
- Upload date:
- Size: 89.6 kB
- Tags: CPython 3.12, macOS 13.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a144a3ae78c467da213f4477bf885103bec646312555f3f0877cbdaee552990a |
|
MD5 | 657f62cae15d85967a2c090d9e2a7d3a |
|
BLAKE2b-256 | 922a22a564d9b238435a925f889560c90cfc4cab769824eee24d1d9786edb71e |
File details
Details for the file reliq-0.0.26-cp312-cp312-macosx_12_0_arm64.whl
.
File metadata
- Download URL: reliq-0.0.26-cp312-cp312-macosx_12_0_arm64.whl
- Upload date:
- Size: 90.6 kB
- Tags: CPython 3.12, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9643ab02b00e3fabee06a63ade3b55c0ba100ac5940164e887a297328f4629f |
|
MD5 | f7b65c984b2a1a458e977207768962f2 |
|
BLAKE2b-256 | 86870ae76fe83d456aa8684e997300d12fbd20a22430ed26693ac8d8b1f755df |
File details
Details for the file reliq-0.0.26-cp310-cp310-manylinux2014_armv7l.whl
.
File metadata
- Download URL: reliq-0.0.26-cp310-cp310-manylinux2014_armv7l.whl
- Upload date:
- Size: 90.1 kB
- Tags: CPython 3.10
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea7c794ab519f10214213ffd4223a7c9fc0622e70cf795a5b358f886b2eb822d |
|
MD5 | 49243927f50e4c7b9261fd58406fe1d6 |
|
BLAKE2b-256 | c1683cb608dbdcc007b89b02401c5fc2d6555e80c71304c108fa07fc34b28c62 |
File details
Details for the file reliq-0.0.26-cp310-cp310-manylinux2014_aarch64.whl
.
File metadata
- Download URL: reliq-0.0.26-cp310-cp310-manylinux2014_aarch64.whl
- Upload date:
- Size: 110.8 kB
- Tags: CPython 3.10
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f78c4d4ac108ad9759e036bf3d8cbf7b403f04bc398688e9855286f12217309 |
|
MD5 | 82f2035e1d531aabc51155e66e91c575 |
|
BLAKE2b-256 | 73448a42c16694306a7868c0b9e89bbb2fc6e29ffc193bd39d63a31abb695855 |