Пример #1
0
def cron_gettr():

    idx = Counter.objects.get(id='DL').number
    while True:
        soup = BeautifulSoup('', 'lxml')
        soup.is_xml = True

        envelope = soup.handle_starttag(
            'Envelope', None,
            'soapenv', {
                'xmlns:soapenv': 'http://schemas.xmlsoap.org/soap/envelope/',
                'xmlns:typ': 'http://isirpublicws.cca.cz/types/'})
        header = soup.new_tag('Header', None, 'soapenv')
        envelope.append(header)
        body = soup.new_tag('Body', None, 'soapenv')
        envelope.append(body)
        req = soup.new_tag('getIsirWsPublicIdDataRequest', None, 'typ')
        body.append(req)
        idPodnetu = soup.new_tag('idPodnetu', None, None)
        idPodnetu.append(str(idx))
        req.append(idPodnetu)
        url = 'https://isir.justice.cz:8443/isir_public_ws/IsirWsPublicService'

        headers = {
            'content-type': 'text/xml; charset=utf-8',
            'SOAPAction': '"http://isirpublicws.cca.cz/types/"',
        }

        res = post(url, soup.renderContents(), headers=headers)

        xml = res.content.decode('utf-8')

        soup = BeautifulSoup(xml, 'lxml')
        soup.is_xml = True

        if not (soup.stav and soup.stav.string == 'OK' and soup.find('data')):
            break

        lst = []
        for t_data in soup.find_all('data'):
            idx = int(t_data.id.string)
            lst.append(Transaction(
                id=idx,
                datumZalozeniUdalosti=convdt(t_data.datumzalozeniudalosti),
                datumZverejneniUdalosti=convdt(t_data.datumzverejneniudalosti),
                dokumentUrl=(t_data.dokumenturl.string.strip() if t_data.dokumenturl else None),
                spisovaZnacka=t_data.spisovaznacka.string.strip(),
                typUdalosti=t_data.typudalosti.string.strip(),
                popisUdalosti=t_data.popisudalosti.string.strip(),
                oddil=(t_data.oddil.string.strip() if t_data.oddil else None),
                cisloVOddilu=(int(t_data.cislovoddilu.string) if t_data.cislovoddilu else None),
                poznamkaText=(t_data.poznamka.string.strip() if t_data.poznamka else None),
                error=False))

        Transaction.objects.bulk_create(lst)
        LOGGER.debug('Read {:d} transaction(s)'.format(len(lst)))
Пример #2
0
def get_ws2(vec):

    soup = BeautifulSoup('', 'lxml')
    soup.is_xml = True

    envelope = soup.handle_starttag(
        'Envelope', None, 'soapenv', {
            'xmlns:soapenv': 'http://schemas.xmlsoap.org/soap/envelope/',
            'xmlns:typ': 'http://isirws.cca.cz/types/'
        })
    header = soup.new_tag('Header', None, 'soapenv')
    envelope.append(header)
    body = soup.new_tag('Body', None, 'soapenv')
    envelope.append(body)
    req = soup.new_tag('getIsirWsCuzkDataRequest', None, 'typ')
    body.append(req)
    bcVec = soup.new_tag('bcVec', None, None)
    bcVec.append(str(vec.bc))
    req.append(bcVec)
    rocnik = soup.new_tag('rocnik', None, None)
    rocnik.append(str(vec.rocnik))
    req.append(rocnik)

    url = 'https://isir.justice.cz:8443/isir_cuzk_ws/IsirWsCuzkService'

    headers = {
        'content-type': 'text/xml; charset=utf-8',
        'SOAPAction': '"http://isirws.cca.cz/types/"',
    }

    res = post(url, soup.renderContents(), headers=headers)

    xml = res.content

    subsoup = BeautifulSoup(xml, 'xml')
    subsoup.is_xml = True

    return subsoup
Пример #3
0
def get_ws2(vec):

    soup = BeautifulSoup('', 'lxml')
    soup.is_xml = True

    envelope = soup.handle_starttag(
        'Envelope', None,
        'soapenv', {
            'xmlns:soapenv': 'http://schemas.xmlsoap.org/soap/envelope/',
            'xmlns:typ': 'http://isirws.cca.cz/types/'})
    header = soup.new_tag('Header', None, 'soapenv')
    envelope.append(header)
    body = soup.new_tag('Body', None, 'soapenv')
    envelope.append(body)
    req = soup.new_tag('getIsirWsCuzkDataRequest', None, 'typ')
    body.append(req)
    bcVec = soup.new_tag('bcVec', None, None)
    bcVec.append(str(vec.bc))
    req.append(bcVec)
    rocnik = soup.new_tag('rocnik', None, None)
    rocnik.append(str(vec.rocnik))
    req.append(rocnik)

    url = 'https://isir.justice.cz:8443/isir_cuzk_ws/IsirWsCuzkService'

    headers = {
        'content-type': 'text/xml; charset=utf-8',
        'SOAPAction': '"http://isirws.cca.cz/types/"',
    }

    res = post(url, soup.renderContents(), headers=headers)

    xml = res.content

    subsoup = BeautifulSoup(xml, 'xml')
    subsoup.is_xml = True

    return subsoup
Пример #4
0
def cron_gettr():

    idx = Counter.objects.get(id='DL').number
    while True:
        soup = BeautifulSoup('', 'lxml')
        soup.is_xml = True

        envelope = soup.handle_starttag(
            'Envelope', None, 'soapenv', {
                'xmlns:soapenv': 'http://schemas.xmlsoap.org/soap/envelope/',
                'xmlns:typ': 'http://isirpublicws.cca.cz/types/'
            })
        header = soup.new_tag('Header', None, 'soapenv')
        envelope.append(header)
        body = soup.new_tag('Body', None, 'soapenv')
        envelope.append(body)
        req = soup.new_tag('getIsirWsPublicIdDataRequest', None, 'typ')
        body.append(req)
        idPodnetu = soup.new_tag('idPodnetu', None, None)
        idPodnetu.append(str(idx))
        req.append(idPodnetu)
        url = 'https://isir.justice.cz:8443/isir_public_ws/IsirWsPublicService'

        headers = {
            'content-type': 'text/xml; charset=utf-8',
            'SOAPAction': '"http://isirpublicws.cca.cz/types/"',
        }

        res = post(url, soup.renderContents(), headers=headers)

        xml = res.content.decode('utf-8')

        soup = BeautifulSoup(xml, 'lxml')
        soup.is_xml = True

        if not (soup.stav and soup.stav.string == 'OK' and soup.find('data')):
            break

        lst = []
        for t_data in soup.find_all('data'):
            idx = int(t_data.id.string)
            lst.append(
                Transaction(id=idx,
                            datumZalozeniUdalosti=convdt(
                                t_data.datumzalozeniudalosti),
                            datumZverejneniUdalosti=convdt(
                                t_data.datumzverejneniudalosti),
                            dokumentUrl=(t_data.dokumenturl.string.strip()
                                         if t_data.dokumenturl else None),
                            spisovaZnacka=t_data.spisovaznacka.string.strip(),
                            typUdalosti=t_data.typudalosti.string.strip(),
                            popisUdalosti=t_data.popisudalosti.string.strip(),
                            oddil=(t_data.oddil.string.strip()
                                   if t_data.oddil else None),
                            cisloVOddilu=(int(t_data.cislovoddilu.string)
                                          if t_data.cislovoddilu else None),
                            poznamkaText=(t_data.poznamka.string.strip()
                                          if t_data.poznamka else None),
                            error=False))

        Transaction.objects.bulk_create(lst)
        LOGGER.debug('Read {:d} transaction(s)'.format(len(lst)))