import json
from datetime import datetime

import requests

from wenshu_utils.cipher import CipherText
from wenshu_utils.des3 import des3decrypt
from wenshu_utils.pageid import PageID
from wenshu_utils.token import RequestVerificationToken


class Demo:
    url = "https://wenshu.court.gov.cn/website/parse/rest.q4w"

    def __init__(self):
        self.session = requests.Session()
        self.session.headers.update({
            "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36",
        })
        # self.session.proxies = # TODO 配置你的代理

    def _request(self, data: dict) -> dict:
        response = self.session.post(self.url, data=data)
        if response.status_code != 200:
            raise Exception(response.status_code)

        json_data = response.json()

        plain_text = des3decrypt(cipher_text=json_data["result"],
                                 key=json_data["secretKey"],
                                 iv=datetime.now().strftime("%Y%m%d"))

        result = json.loads(plain_text)
        return result

    def list_page(self):
        data = {
            "pageId": PageID(),
            "sortFields": "s50:desc",
            "ciphertext": CipherText(),
            "pageNum": 1,
            "pageSize": 5,
            "queryCondition": json.dumps([{"key": "s8", "value": "03"}]),  # 查询条件: s8=案件类型, 03=民事案件
            "cfg": "com.lawyee.judge.dc.parse.dto.SearchDataDsoDTO@queryDoc",
            "__RequestVerificationToken": RequestVerificationToken(24),
        }

        result = self._request(data)
        print(result)

    def detail_page(self):
        data = {
            "docId": "4e00b8ae589b4288a725aabe00c0e683",
            "ciphertext": CipherText(),
            "cfg": "com.lawyee.judge.dc.parse.dto.SearchDataDsoDTO@docInfoSearch",
            "__RequestVerificationToken": RequestVerificationToken(24),
        }

        result = self._request(data)
        print(result)


if __name__ == '__main__':
    demo = Demo()
    demo.list_page()
    demo.detail_page()

ce4d818338ba932df783e8425c82312e806e8ec7
<mask token>


class Demo:
    <mask token>

    def __init__(self):
        self.session = requests.Session()
        self.session.headers.update({'User-Agent':
            'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36'
            })

    def _request(self, data: dict) ->dict:
        response = self.session.post(self.url, data=data)
        if response.status_code != 200:
            raise Exception(response.status_code)
        json_data = response.json()
        plain_text = des3decrypt(cipher_text=json_data['result'], key=
            json_data['secretKey'], iv=datetime.now().strftime('%Y%m%d'))
        result = json.loads(plain_text)
        return result

    def list_page(self):
        data = {'pageId': PageID(), 'sortFields': 's50:desc', 'ciphertext':
            CipherText(), 'pageNum': 1, 'pageSize': 5, 'queryCondition':
            json.dumps([{'key': 's8', 'value': '03'}]), 'cfg':
            'com.lawyee.judge.dc.parse.dto.SearchDataDsoDTO@queryDoc',
            '__RequestVerificationToken': RequestVerificationToken(24)}
        result = self._request(data)
        print(result)

    def detail_page(self):
        data = {'docId': '4e00b8ae589b4288a725aabe00c0e683', 'ciphertext':
            CipherText(), 'cfg':
            'com.lawyee.judge.dc.parse.dto.SearchDataDsoDTO@docInfoSearch',
            '__RequestVerificationToken': RequestVerificationToken(24)}
        result = self._request(data)
        print(result)


<mask token>

<mask token>


class Demo:
    url = 'https://wenshu.court.gov.cn/website/parse/rest.q4w'

    def __init__(self):
        self.session = requests.Session()
        self.session.headers.update({'User-Agent':
            'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36'
            })

    def _request(self, data: dict) ->dict:
        response = self.session.post(self.url, data=data)
        if response.status_code != 200:
            raise Exception(response.status_code)
        json_data = response.json()
        plain_text = des3decrypt(cipher_text=json_data['result'], key=
            json_data['secretKey'], iv=datetime.now().strftime('%Y%m%d'))
        result = json.loads(plain_text)
        return result

    def list_page(self):
        data = {'pageId': PageID(), 'sortFields': 's50:desc', 'ciphertext':
            CipherText(), 'pageNum': 1, 'pageSize': 5, 'queryCondition':
            json.dumps([{'key': 's8', 'value': '03'}]), 'cfg':
            'com.lawyee.judge.dc.parse.dto.SearchDataDsoDTO@queryDoc',
            '__RequestVerificationToken': RequestVerificationToken(24)}
        result = self._request(data)
        print(result)

    def detail_page(self):
        data = {'docId': '4e00b8ae589b4288a725aabe00c0e683', 'ciphertext':
            CipherText(), 'cfg':
            'com.lawyee.judge.dc.parse.dto.SearchDataDsoDTO@docInfoSearch',
            '__RequestVerificationToken': RequestVerificationToken(24)}
        result = self._request(data)
        print(result)


<mask token>

<mask token>


class Demo:
    url = 'https://wenshu.court.gov.cn/website/parse/rest.q4w'

    def __init__(self):
        self.session = requests.Session()
        self.session.headers.update({'User-Agent':
            'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36'
            })

    def _request(self, data: dict) ->dict:
        response = self.session.post(self.url, data=data)
        if response.status_code != 200:
            raise Exception(response.status_code)
        json_data = response.json()
        plain_text = des3decrypt(cipher_text=json_data['result'], key=
            json_data['secretKey'], iv=datetime.now().strftime('%Y%m%d'))
        result = json.loads(plain_text)
        return result

    def list_page(self):
        data = {'pageId': PageID(), 'sortFields': 's50:desc', 'ciphertext':
            CipherText(), 'pageNum': 1, 'pageSize': 5, 'queryCondition':
            json.dumps([{'key': 's8', 'value': '03'}]), 'cfg':
            'com.lawyee.judge.dc.parse.dto.SearchDataDsoDTO@queryDoc',
            '__RequestVerificationToken': RequestVerificationToken(24)}
        result = self._request(data)
        print(result)

    def detail_page(self):
        data = {'docId': '4e00b8ae589b4288a725aabe00c0e683', 'ciphertext':
            CipherText(), 'cfg':
            'com.lawyee.judge.dc.parse.dto.SearchDataDsoDTO@docInfoSearch',
            '__RequestVerificationToken': RequestVerificationToken(24)}
        result = self._request(data)
        print(result)


if __name__ == '__main__':
    demo = Demo()
    demo.list_page()
    demo.detail_page()

import json
from datetime import datetime
import requests
from wenshu_utils.cipher import CipherText
from wenshu_utils.des3 import des3decrypt
from wenshu_utils.pageid import PageID
from wenshu_utils.token import RequestVerificationToken


class Demo:
    url = 'https://wenshu.court.gov.cn/website/parse/rest.q4w'

    def __init__(self):
        self.session = requests.Session()
        self.session.headers.update({'User-Agent':
            'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36'
            })

    def _request(self, data: dict) ->dict:
        response = self.session.post(self.url, data=data)
        if response.status_code != 200:
            raise Exception(response.status_code)
        json_data = response.json()
        plain_text = des3decrypt(cipher_text=json_data['result'], key=
            json_data['secretKey'], iv=datetime.now().strftime('%Y%m%d'))
        result = json.loads(plain_text)
        return result

    def list_page(self):
        data = {'pageId': PageID(), 'sortFields': 's50:desc', 'ciphertext':
            CipherText(), 'pageNum': 1, 'pageSize': 5, 'queryCondition':
            json.dumps([{'key': 's8', 'value': '03'}]), 'cfg':
            'com.lawyee.judge.dc.parse.dto.SearchDataDsoDTO@queryDoc',
            '__RequestVerificationToken': RequestVerificationToken(24)}
        result = self._request(data)
        print(result)

    def detail_page(self):
        data = {'docId': '4e00b8ae589b4288a725aabe00c0e683', 'ciphertext':
            CipherText(), 'cfg':
            'com.lawyee.judge.dc.parse.dto.SearchDataDsoDTO@docInfoSearch',
            '__RequestVerificationToken': RequestVerificationToken(24)}
        result = self._request(data)
        print(result)


if __name__ == '__main__':
    demo = Demo()
    demo.list_page()
    demo.detail_page()

import json
from datetime import datetime

import requests

from wenshu_utils.cipher import CipherText
from wenshu_utils.des3 import des3decrypt
from wenshu_utils.pageid import PageID
from wenshu_utils.token import RequestVerificationToken


class Demo:
    url = "https://wenshu.court.gov.cn/website/parse/rest.q4w"

    def __init__(self):
        self.session = requests.Session()
        self.session.headers.update({
            "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36",
        })
        # self.session.proxies = # TODO 配置你的代理

    def _request(self, data: dict) -> dict:
        response = self.session.post(self.url, data=data)
        if response.status_code != 200:
            raise Exception(response.status_code)

        json_data = response.json()

        plain_text = des3decrypt(cipher_text=json_data["result"],
                                 key=json_data["secretKey"],
                                 iv=datetime.now().strftime("%Y%m%d"))

        result = json.loads(plain_text)
        return result

    def list_page(self):
        data = {
            "pageId": PageID(),
            "sortFields": "s50:desc",
            "ciphertext": CipherText(),
            "pageNum": 1,
            "pageSize": 5,
            "queryCondition": json.dumps([{"key": "s8", "value": "03"}]),  # 查询条件: s8=案件类型, 03=民事案件
            "cfg": "com.lawyee.judge.dc.parse.dto.SearchDataDsoDTO@queryDoc",
            "__RequestVerificationToken": RequestVerificationToken(24),
        }

        result = self._request(data)
        print(result)

    def detail_page(self):
        data = {
            "docId": "4e00b8ae589b4288a725aabe00c0e683",
            "ciphertext": CipherText(),
            "cfg": "com.lawyee.judge.dc.parse.dto.SearchDataDsoDTO@docInfoSearch",
            "__RequestVerificationToken": RequestVerificationToken(24),
        }

        result = self._request(data)
        print(result)


if __name__ == '__main__':
    demo = Demo()
    demo.list_page()
    demo.detail_page()
