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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file reliq-0.0.27.tar.gz.
File metadata
- Download URL: reliq-0.0.27.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c43cd1c95aefd6411c5913a1732793ec2ae8724fa7edcca8e428a7dc42cf67cf
|
|
| MD5 |
e6f2d49ac4efba75cf31bcad98c0e210
|
|
| BLAKE2b-256 |
8ec1ec11858f3ed21315e75b9e0d7056d370523688fa573a4e11e43a4775b229
|
File details
Details for the file reliq-0.0.27-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: reliq-0.0.27-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 145.9 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b39cdfc6ebed3919e53b2a666a6de8be845243b439ab65ac69e912a05f18c83
|
|
| MD5 |
a78fb267dc178d7bac0fcdc111b78c25
|
|
| BLAKE2b-256 |
6de34de71d6f64c8767e130434ccc25a075ff272766031a231e42aa3f5f5f4a8
|
File details
Details for the file reliq-0.0.27-cp312-cp312-manylinux2014_x86_64.whl.
File metadata
- Download URL: reliq-0.0.27-cp312-cp312-manylinux2014_x86_64.whl
- Upload date:
- Size: 117.0 kB
- Tags: CPython 3.12
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4662e48c52c8faa32c6ce39caca3ff949b19e1ad34a28409204ef02aaecd562d
|
|
| MD5 |
1c0b36dc3e3ff4ae8b7fd20b10cc1e07
|
|
| BLAKE2b-256 |
57ce338dcbf1455cad6388eceeeaada8702baccbc12d5f832c4f25161fa1d05b
|
File details
Details for the file reliq-0.0.27-cp312-cp312-macosx_13_0_arm64.whl.
File metadata
- Download URL: reliq-0.0.27-cp312-cp312-macosx_13_0_arm64.whl
- Upload date:
- Size: 91.2 kB
- Tags: CPython 3.12, macOS 13.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c1e1428e7d3c654c6fe804a58496a3436aa4eef8c502746f82e15b44aef94b5
|
|
| MD5 |
61578df5b8e5f57fbb184267934429ef
|
|
| BLAKE2b-256 |
295f30009fc8e44f1691286765d7a242bf4212c4603e3a47286c4299b4c09c0b
|
File details
Details for the file reliq-0.0.27-cp312-cp312-macosx_12_0_arm64.whl.
File metadata
- Download URL: reliq-0.0.27-cp312-cp312-macosx_12_0_arm64.whl
- Upload date:
- Size: 92.1 kB
- Tags: CPython 3.12, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e65f1f329451792831fdad3c7b90957f85c493aa3238ae12648374ee2fbbe2dd
|
|
| MD5 |
b3984f0fd391511c82f1689c56600c46
|
|
| BLAKE2b-256 |
608ceb322287419feff96843f5275a2337197ca1c2efbab12977eeec9f78e51a
|
File details
Details for the file reliq-0.0.27-cp310-cp310-manylinux2014_armv7l.whl.
File metadata
- Download URL: reliq-0.0.27-cp310-cp310-manylinux2014_armv7l.whl
- Upload date:
- Size: 92.8 kB
- Tags: CPython 3.10
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ceba06019e4ceba170e1e1a804ce2606b4edeeec2011dee0604d72d3ed34f60a
|
|
| MD5 |
ffce9d1c2c09e03b92a656eca08d3d9b
|
|
| BLAKE2b-256 |
d146d747088adacdcc498498ce228a7c06ce23130bf2981879a67298f7182605
|
File details
Details for the file reliq-0.0.27-cp310-cp310-manylinux2014_aarch64.whl.
File metadata
- Download URL: reliq-0.0.27-cp310-cp310-manylinux2014_aarch64.whl
- Upload date:
- Size: 113.4 kB
- Tags: CPython 3.10
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
585e889744b84889fe47702ac3db5d98e13a6dec4bb38d7eb73e55dadcc4617a
|
|
| MD5 |
72c9ca6afaa92dd288634bff8bc29921
|
|
| BLAKE2b-256 |
5686f297a1b392c81b654e6b39054dd3f7bc00f8b11efe5bbec571f6132a4093
|