Create a gist now

Instantly share code, notes, and snippets.

Embed search "API"
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from pyquery import PyQuery as pq
class JusticePy(object):
URL = '*&hledani.format.obchodniJmeno=platne&hledani.podminka.pravniForma=-1&hledani.podminka.ulice='
ALLOWED = ('subject', 'ic')
def search(self, **kwargs):
sprints = {}
for one in self.ALLOWED:
sprints[one] = ''
doc = pq(url=self.URL % sprints)
return self._parse_result(doc)
def _parse_result(self, html):
parsed = []
for one in pq(html).find('img.cara + table + table'):
return parsed
def _parse_one(self, item):
keys = ('court_id', 'subject', 'ic', 'address', 'from')
parsed = {}
for pos, one in enumerate(pq(item).find('tr td')[1::2]):
parsed[keys[pos]] = pq(one).text()
return parsed
if __name__ == '__main__':
print JusticePy().search(subject='construct')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment