Esempio n. 1
0
    def test_list(self):
        response = self.session.get("http://wenshu.court.gov.cn/list/list/")
        text = response.content.decode()

        if self.error_msg in text:
            redirect_url1 = wzws_decrypt(text, url=response.url)
            redirect_url2 = wzws_decrypt(text)
            self.assertEqual(redirect_url1, redirect_url2)

            _ = self.session.get(redirect_url1)

        url = "http://wenshu.court.gov.cn/List/ListContent"
        data = {
            "Param": "案件类型:行政案件",
            "Index": 1,
            "Page": 10,
            "Order": "法院层级",
            "Direction": "asc",
            "vl5x": Vl5x(self.session.cookies["vjkl5"]),
            "number": Number(),
            "guid": Guid(),
        }
        response = self.session.post(url, data=data)

        self.assertNotIn(self.error_msg, response.content.decode())
        print(response.text)
Esempio n. 2
0
    def test_request_process(self):
        vjkl5 = Vjkl5()
        self.session.cookies["vjkl5"] = vjkl5

        url = "http://wenshu.court.gov.cn/List/ListContent"
        data = {
            "Param": "案件类型:执行案件",
            "Index": 1,
            "Page": 10,
            "Order": "法院层级",
            "Direction": "asc",
            "vl5x": Vl5x(vjkl5),
            "number": Number(),
            "guid": Guid(),
        }
        response = self.session.post(url, data=data)

        json_data = json.loads(response.json())
        print("列表数据:", json_data)

        run_eval = json_data.pop(0)["RunEval"]
        try:
            key = parse_run_eval(run_eval)
        except ValueError as e:
            raise ValueError("返回脏数据") from e
        else:
            print("RunEval解析完成:", key, "\n")

        key = key.encode()
        for item in json_data:
            cipher_text = item["文书ID"]
            print("解密:", cipher_text)
            plain_text = decrypt_doc_id(doc_id=cipher_text, key=key)
            print("成功, 文书ID:", plain_text, "\n")

        # 请求详情页
        detail_url = "http://wenshu.court.gov.cn/CreateContentJS/CreateContentJS.aspx"
        params = {
            "DocID": decrypt_doc_id(doc_id=json_data[0]["文书ID"], key=key),
        }
        response = self.session.get(detail_url, params=params)
        text = response.content.decode()

        if self.error_msg in text:
            redirect_url1 = wzws_decrypt(text, url=response.url)
            redirect_url2 = wzws_decrypt(text)
            self.assertEqual(redirect_url1, redirect_url2)

            response = self.session.get(redirect_url1)

        self.assertNotIn(self.error_msg, response.content.decode())

        group_dict = parse_detail(response.text)
        pprint(group_dict)
Esempio n. 3
0
def request_detail():
    """请求详情数据"""
    session = requests.Session()
    session.headers.update({
        "User-Agent":
        "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36",
    })

    url = "http://wenshu.court.gov.cn/CreateContentJS/CreateContentJS.aspx"
    params = {
        "DocID":
        "029bb843-b458-4d1c-8928-fe80da403cfe",  # TODO 太多人测试此DocID,如果报错请更换DocID进行测试
    }
    response = session.get(url, params=params)
    text = response.content.decode()

    if "请开启JavaScript并刷新该页" in text:
        # 如果有当前请求的url,尽量把url传进去,会更快一些
        redirect_url = wzws_decrypt(text, url=response.url)
        # 没有url就算了
        # redirect_url = wzws_decrypt(text)

        response = session.get(redirect_url)

    group_dict = parse_detail(response.text)
    pprint(group_dict)
Esempio n. 4
0
    def test_detail(self):
        url = "http://wenshu.court.gov.cn/CreateContentJS/CreateContentJS.aspx"
        params = {
            "DocID": "efeba473-b647-11e3-84e9-5cf3fc0c2c18",
        }
        response = self.session.get(url, params=params)
        text = response.content.decode()

        if self.error_msg in text:
            redirect_url1 = wzws_decrypt(text, url=response.url)
            redirect_url2 = wzws_decrypt(text)
            self.assertEqual(redirect_url1, redirect_url2)

            response = self.session.get(redirect_url1)

        self.assertNotIn(self.error_msg, response.content.decode())
        print(response.text)
Esempio n. 5
0
    def test_detail(self):
        url = "http://wenshu.court.gov.cn/CreateContentJS/CreateContentJS.aspx"
        params = {
            "DocID": "13d4c01a-0734-4ec1-bbac-658f8bb8ec62",
        }
        response = self.session.get(url, params=params)
        text = response.content.decode()

        if self.error_msg in text:
            redirect_url1 = wzws_decrypt(text, url=response.url)
            redirect_url2 = wzws_decrypt(text)
            self.assertEqual(redirect_url1, redirect_url2)

            response = self.session.get(redirect_url1)

        self.assertNotIn(self.error_msg, response.content.decode())
        print(response.text)
    def test_detail_parse(self):
        url = "http://wenshu.court.gov.cn/CreateContentJS/CreateContentJS.aspx"
        params = {
            "DocID": "a8b745f3-43ac-402c-99bf-68b9a9cae635",
        }
        response = self.session.get(url, params=params)
        text = response.content.decode()

        if self.error_msg in text:
            redirect_url = wzws_decrypt(text)
            response = self.session.get(redirect_url)

        self.assertNotIn(self.error_msg, response.content.decode())

        group_dict = parse_detail(response.text)
        pprint(group_dict)
Esempio n. 7
0
    def test_detail_parse(self):
        url = "http://wenshu.court.gov.cn/CreateContentJS/CreateContentJS.aspx"
        params = {
            "DocID": "2e509686-62f9-4cf8-beeb-a7fe00ebcb05",
        }
        response = self.session.get(url, params=params)
        text = response.content.decode()

        if self.error_msg in text:
            redirect_url = wzws_decrypt(text)
            response = self.session.get(redirect_url)

        self.assertNotIn(self.error_msg, response.content.decode())

        group_dict = parse_detail(response.text)
        pprint(group_dict)