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)
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"
}
""")
users = []
links = []
images = []
for i in rq.filter(r'table; tr').self()[:-2]:
if i.child_count() < 3 and i[0].tag() == "div":
continue
link = i[5].attribs()['href']
if re.match('^https://$',href):
links.append(link)
continue
user = json.loads(i.search(expr))
users.append(user)
for i in reliq.fsearch(r'ul; img src | "%(src)v\n"',html).split('\n')[:-1]:
images.append(i)
try:
reliq.fsearch('p / /','<p></p>')
except ReliqError:
print("error")
Projects using reliq