ddddocr使用案例,保存验证码识别并验证,四位数字验证码识别率高达90%

import json
from urllib.parse import urlencode

import scrapy

from lxml import etree
import requests
# from readability import Document
from lxml import etree
import re
import html2text
import pandas as pd
from lxml import etree
import time
import scrapy,html2text
import datetime
from lxml import etree
from inline_requests import inline_requests
from fake_useragent import UserAgent

from items import MyscrapyRedisItem
from dataprocess import same_certId_def, region_name_to_Region_code_v2

import time
import ddddocr
import requests


class MajorProjectsSpider(scrapy.Spider):
    name = 'jiangsu'
    city="jiangsu"
    # province=""
    allowed_domains = ['http://58.213.147.230:7001/Jsjzyxyglpt/faces/public/qyxx5c/fdcqyList.jsp']

    cookies = {
        'JSESSIONID': '9453688B635C7F4C55FE549B80B43672',
        'SERVERID': 'e357df2bda02e2fe0eb8d8524247563e^|1668752895^|1668752815',
    }

    headers = {
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
        # 'Accept-Encoding': 'gzip, deflate',
        # 'Accept-Language': 'zh-CN,zh;q=0.9',
        # 'Cache-Control': 'no-cache',
        # 'Connection': 'keep-alive',
        # 'Host': '58.213.147.230:7001',
        # 'Pragma': 'no-cache',
        # 'Cookie': f'sanyousoft={soft_cookie}',
        'Referer': 'http://58.213.147.230:7001/Jsjzyxyglpt/faces/public/qyxx5c/fdcqyList.jsp',
        # 'Upgrade-Insecure-Requests': '1',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36',
    }


    def start_requests(self):  # 必要的请求结构
        # start_urls = ["https://js.shaanxi.gov.cn:9010/SxApp/share/WebSide/ZZCXList.aspx?fcol=800019"]
        # url1='http://58.213.147.230:7001/Jsjzyxyglpt/faces//public/qyxx5c/fdcqyList.jsp?dataType=website-qyxx-fdcqy&menucode=0310'


        # session = requests.session()
        resp = requests.get(
            'http://58.213.147.230:7001/Jsjzyxyglpt/faces//public/qyxx5c/fdcqyList.jsp?dataType=website-qyxx-fdcqy&menucode=0310',
            headers={
                'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
                # 'Accept-Encoding': 'gzip, deflate',
                # 'Accept-Language': 'zh-CN,zh;q=0.9',
                # 'Cache-Control': 'no-cache',
                # 'Connection': 'keep-alive',
                # 'Host': '58.213.147.230:7001',
                # 'Pragma': 'no-cache',
                # 'Cookie': f'sanyousoft={soft_cookie}',
                'Referer': 'http://58.213.147.230:7001/Jsjzyxyglpt/faces/public/qyxx5c/fdcqyList.jsp',
                # 'Upgrade-Insecure-Requests': '1',
                'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36',
            }
        )
        soft_cookie = resp.cookies.get('sanyousoft')
        resp1 = requests.get(
            'http://58.213.147.230:7001/Jsjzyxyglpt/faces/public/checkCode.jsp?action=regenerate&height=38&width=90',
            headers={
                'Accept': 'image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8',
                # 'Accept-Encoding': 'gzip, deflate',
                # 'Accept-Language': 'zh-CN,zh;q=0.9',
                # 'Cache-Control': 'no-cache',
                # 'Connection': 'keep-alive',
                'Cookie': f'sanyousoft={soft_cookie}',
                'Host': '58.213.147.230:7001',
                'Pragma': 'no-cache',
                'Referer': 'http://58.213.147.230:7001/Jsjzyxyglpt/faces/public/qyxx5c/fdcqyList.jsp',
                'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36',
            }
        )
        # print(resp1.cookies)
        # soft_cookie = resp1.cookies.get('sanyousoft')
        with open('code.jpg', 'wb') as f:
            f.write(resp1.content)
        # soft_cookie = resp.cookies.get('sanyousoft')
        ocr = ddddocr.DdddOcr(show_ad=False)
        code = ocr.classification(resp1.content)
        # print(soft_cookie)
        data = 'action=isValidCheckCode&checkCode=%s' % code
        resp2 = requests.post(
            'http://58.213.147.230:7001/Jsjzyxyglpt/faces/public/action.jsp',
            data=data,
            headers={
                'Accept': 'application/json, text/javascript, */*; q=0.01',
                # 'Accept-Encoding': 'gzip, deflate',
                # 'Accept-Language': 'zh-CN,zh;q=0.9',
                # 'Cache-Control': 'no-cache',
                # 'Connection': 'keep-alive',
                # 'Content-Length': '38',
                'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
                'Cookie': f'sanyousoft={soft_cookie};Hm_lvt_3ad329b09e33cc3badcbfc2b7a6e5f4c={int(time.time())}; Hm_lpvt_3ad329b09e33cc3badcbfc2b7a6e5f4c={int(time.time())}',
                'Host': '58.213.147.230:7001',
                'Origin': 'http://58.213.147.230:7001',
                # 'Pragma': 'no-cache',
                'Referer': 'http://58.213.147.230:7001/Jsjzyxyglpt/faces/public/qyxx5c/fdcqyList.jsp',
                'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36',
                'X-Requested-With': 'XMLHttpRequest',
            }
        )
        print(resp2.text)
        # import requests
        # url = f'http://58.213.147.230:7001/Jsjzyxyglpt/faces/public/qyxx5c/fdcqyList.jsp;sanyousoft={soft_cookie}'
        from urllib import parse
        page = 1
        for k in range(1,3):
            url = 'http://58.213.147.230:7001/Jsjzyxyglpt/faces/public/qyxx5c/fdcqyList.jsp'
            if page == 1:
                data = {
                    'msgWinSelectedTabPageIndex': '1',
                    'form:page': '1',
                    'form:qymc': '',
                    'form:shxydm': '',
                    'form:search1': '徐州市'.encode("GBK"),  # parse.quote('徐州市', encoding='gbk'),
                    'form:search2': '暂定贰级'.encode("GBK"),  # parse.quote('暂定贰级', encoding='gbk'),
                    'form:checkCode': code,
                    'com.sun.faces.VIEW': 'rO0ABXNyACBjb20uc3VuLmZhY2VzLnV0aWwuVHJlZVN0c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AAAAHVxAH4AHgAAAAJ1cQB+AB4AAAAfdXEAfgAeAAAACnVxAH4AHgAAAAN1cQB+AB4AAAAIc3EAfgAjP0AAAAAAAAx3CAAAABAAAAAAeHVxAH4AHgAAAAJ1cQB+AFYAAAABcQB+AFh1cQB+AB4AAAABc3EAfgBEcQB+AEt0ABlDb21tb25RdWVyeUJlYW4uY2hlY2tDb2RldAAOZm9ybTpjaGVja0NvZGVxAH4AGXEAfgAocQB+AClxAH4Aa3BwcHEAfgApcQB+AClxAH4AKXEAfgAocQB+AClxAH4AKXBwcHBwcHEAfgApcQB+AClwc3EAfgBsgAAAAHEAfgApcHBwcHBwcHBwcHBwcHBxAH4AKXEAfgApc3EAfgBsgAAAAHEAfgApdAAMd2lkdGg6MTc1cHg7cQB+ABVwcHVxAH4AHgAAAAA=',
                    'form': 'form',
                    'form:_idcl': 'form:refreshAct',
                }
                # data = f'msgWinSelectedTabPageIndex=1&form%3Apage=1&form%3Aqymc=&form%3Ashxydm=&form%3Asearch1=&form%3Asearch2=&form%3AcheckCode={res}&com.sun.faces.VIEW=rO0ABXNyACBjb20uc3VuLmZhY2VzLnV0aWwuVHJlZVN0cnVjdHVyZRRmG0QclWAgAgAETAAIY2hpbGRyZW50ABVMamF2YS91dGlsL0FycmF5TGlzdDtMAAljbGFzc05hbWV0ABJMamF2YS9sYW5nL1N0cmluZztMAAZmYWNldHN0ABNMamF2YS91dGlsL0hhc2hNYXA7TAACaWRxAH4AAnhwc3IAE2phdmEudXRpbC5BcnJheUxpc3R4gdIdmcdhnQMAAUkABHNpemV4cAAAAAF3BAAAAAFzcQB%2BAABzcQB%2BAAUAAAAHdwQAAAAHc3EAfgAAcHQAKmphdmF4LmZhY2VzLmNvbXBvbmVudC5odG1sLkh0bWxDb21tYW5kTGlua3B0AApyZWZyZXNoQWN0c3EAfgAAcHQAKmphdmF4LmZhY2VzLmNvbXBvbmVudC5odG1sLkh0bWxJbnB1dEhpZGRlbnB0AARwYWdlc3EAfgAAcHQAKG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EAfgAocQB%2BAClxAH4AKXBwcHBwcHEAfgApcQB%2BAClwc3EAfgBsgAAAAHEAfgApcHBwcHBwcHBwcHBwcHBxAH4AKXEAfgApc3EAfgBsgAAAAHEAfgApdAAMd2lkdGg6MTc1cHg7cQB%2BABVwcHVxAH4AHgAAAAA%3D&form=form&form%3A_idcl=form%3ArefreshAct'
            else:
                # data = f'msgWinSelectedTabPageIndex=1&form%3Apage={page}&form%3Aqymc=%C6%F3%D2%B5%C3%FB%B3%C6&form%3Ashxydm=%C6%F3%D2%B5%CD%B3%D2%BB%C9%E7%BB%E1%D0%C5%D3%C3%B4%FA%C2%EB&form%3Asearch1=&form%3Asearch2=&form%3AcheckCode={res}&pageSize=30&com.sun.faces.VIEW=rO0ABXNyACBjb20uc3VuLmZhY2VzLnV0aWwuVHJlZVN0cnVjdHVyZRRmG0QclWAgAgAETAAIY2hpbGRyZW50ABVMamF2YS91dGlsL0FycmF5TGlzdDtMAAljbGFzc05hbWV0ABJMamF2YS9sYW5nL1N0cmluZztMAAZmYWNldHN0ABNMamF2YS91dGlsL0hhc2hNYXA7TAACaWRxAH4AAnhwc3IAE2phdmEudXRpbC5BcnJheUxpc3R4gdIdmcdhnQMAAUkABHNpemV4cAAAAAF3BAAAAAFzcQB%2BAABzcQB%2BAAUAAAAHdwQAAAAHc3EAfgAAcHQAKmphdmF4LmZhY2VzLmNvbXBvbmVudC5odG1sLkh0bWxDb21tYW5kTGlua3B0AApyZWZyZXNoQWN0c3EAfgAAcHQAKmphdmF4LmZhY2VzLmNvbXBvbmVudC5odG1sLkh0bWxJbnB1dEhpZGRlbnB0AARwYWdlc3EAfgAAcHQAKGphdmF4LmZhY2VzLmNvbXBvbmVudC5odG1sLkh0bWxJbnB1dFRleHRwdAAEcXltY3NxAH4AAHBxAH4AEHB0AAZzaHh5ZG1zcQB%2BAABwcQB%2BAA1wdAAHc2VhcmNoMXNxAH4AAHBxAH4ADXB0AAdzZWFyY2gyc3EAfgAAcHEAfgAQcHQACWN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= {
                    'msgWinSelectedTabPageIndex': '1',
                    'form:page': page,
                    'form:qymc': '企业名称'.encode("GBK"),  # parse.quote('企业名称', encoding='gbk'),
                    'form:shxydm': '企业统一社会信用代码'.encode("GBK"),  # parse.quote('企业统一社会信用代码', encoding='gbk'),
                    'form:search1': '徐州市'.encode("GBK"),  # parse.quote('徐州市', encoding='gbk'),
                    'form:search2': '暂定贰级'.encode("GBK"),  # parse.quote('暂定贰级', encoding='gbk'),
                    'form:checkCode': code,
                    'com.sun.faces.VIEW': 'rO0ABXNyACBjb20uc3VuLmZhY2VzLnV0aWwuVHJlZVN0cnVjdHVyZRRmG0QclWAgAgAETAAIY2hpbGRyZW50ABVMamF2YS91dGlsL0FycmF5TGlzdDtMAAljbGFzc05hbWV0ABJMamF2YS9sYW5nL1N0cmluZztMAAZmYWNldHN0ABNMamF2YS91dGlsL0hhc2hNYXA7TAACaWRxAH4AAnhwc3IAE2phdmEudXRpbC5BcnJheUxpc3R4gdIdmcdhnQMAAUkABHNpemV4cAAAAAF3BAAAAAFzcQB+AABzcQB+AAUAAAAHdwQAAAAHc3EAfgAAcHQAKmphdmF4LmZhY2VzLmNvbXBvbmVudC5odG1sLkh0bWxDb21tYW5kTGlua3B0AApyZWZyZXNoQWN0c3EAfgAAcHQAKmphdmF4LmZhY2VzLmNvbXBvbmVudC5odG1sLkh0bWxJbnB1dEhpZGRlbnB0AARwYWdlc3EAfgAAcHQAKGphdmF4LmZhY2VzLmNvbXBvbmVudC5odG1sLkh0bWxJbnB1dFRleHRwdAAEcXltY3NxAH4AAHBxAH4AEHB0AAZzaHh5ZG1zcQB+AABwcQB+AA1wdAAHc2VhcmNoMXNxAH4AAHBxAH4ADXB0AAdzZWFyY2gyc3EAfgAAcHEAfgAQcHQACWNoZWNrQ29kZXh0ACNqYXZheC5mYWNlcy5jb21wb25lbnQuaHRtbC5IdG1sRm9ybXB0AARmb3JteHQAKG9yZy5hamF4NGpzZi5mcmFtZXdvcmsuYWpheC5BamF4Vmlld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cHBwdXEAfgAeAAAAAHVxAH4AHgAAAAJ1cQB+AB4AAAABdXEAfgAeAAAACnVxAH4AHgAAAAN1cQB+AB4AAAAIc3EAfgAjP0AAAAAAAAx3CAAAABAAAAAAeHVxAH4AHgAAAAJ1cQB+AFYAAAABcQB+AFh1cQB+AB4AAAABc3EAfgBEcQB+AEt0AB1Db21tb25RdWVyeUJlYW4uZmlsdGVyLmZpZWxkNnQADGZvcm06c2VhcmNoMnEAfgAXcQB+AChxAH4AKXEAfgBdcHBwcQB+AClxAH4AKXEAfgApcQB+AChxAH4AKXEAfgApcHBwdXEAfgAeAAAAAHVxAH4AHgAAAAJ1cQB+AB4AAAAfdXEAfgAeAAAACnVxAH4AHgAAAAN1cQB+AB4AAAAIc3EAfgAjP0AAAAAAAAx3CAAAABAAAAAAeHVxAH4AHgAAAAJ1cQB+AFYAAAABcQB+AFh1cQB+AB4AAAABc3EAfgBEcQB+AEt0ABlDb21tb25RdWVyeUJlYW4uY2hlY2tDb2RldAAOZm9ybTpjaGVja0NvZGVxAH4AGXEAfgAocQB+AClxAH4Aa3BwcHEAfgApcQB+AClxAH4AKXEAfgAocQB+AClxAH4AKXBwcHBwcHEAfgApcQB+AClwc3EAfgBsgAAAAHEAfgApcHBwcHBwcHBwcHBwcHBxAH4AKXEAfgApc3EAfgBsgAAAAHEAfgApdAAMd2lkdGg6MTc1cHg7cQB+ABVwcHVxAH4AHgAAAAA=',
                    'form': 'form',
                    'form:_idcl': '',
                }

            # data = f'msgWinSelectedTabPageIndex=1&form%3Apage={page}&form%3Aqymc=%C6%F3%D2%B5%C3%FB%B3%C6&form%3Ashxydm=%C6%F3%D2%B5%CD%B3%D2%BB%C9%E7%BB%E1%D0%C5%D3%C3%B4%FA%C2%EB&form%3Asearch1=&form%3Asearch2=&form%3AcheckCode={res}&pageSize=30&com.sun.faces.VIEW=rO0ABXNyACBjb20uc3VuLmZhY2VzLnV0aWwuVHJlZVN0cnVjdHVyZRRmG0QclWAgAgAETAAIY2hp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yLmZpZWxkNnQADGZvcm06c2VhcmNoMnEAfgAXcQB%2BAChxAH4AKXEAfgBdcHBwcQB%2BAClxAH4AKXEAfgApcQB%2BAChxAH4AKXEAfgApcHBwdXEAfgAeAAAAAHVxAH4AHgAAAAJ1cQB%2BAB4AAAAfdXEAfgAeAAAACnVxAH4AHgAAAAN1cQB%2BAB4AAAAIc3EAfgAjP0AAAAAAAAx3CAAAABAAAAAAeHVxAH4AHgAAAAJ1cQB%2BAFYAAAABcQB%2BAFh1cQB%2BAB4AAAABc3EAfgBEcQB%2BAEt0ABlDb21tb25RdWVyeUJlYW4uY2hlY2tDb2RldAAOZm9ybTpjaGVja0NvZGVxAH4AGXEAfgAocQB%2BAClxAH4Aa3BwcHEAfgApcQB%2BAClxAH4AKXEAfgAocQB%2BAClxAH4AKXBwcHBwcHEAfgApcQB%2BAClwc3EAfgBsgAAAAHEAfgApcHBwcHBwcHBwcHBwcHBxAH4AKXEAfgApc3EAfgBsgAAAAHEAfgApdAAMd2lkdGg6MTc1cHg7cQB%2BABVwcHVxAH4AHgAAAAA%3D&form=form&form%3A_idcl='
            headers = {
                'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
                # 'Accept-Encoding': 'gzip, deflate',
                # 'Accept-Language': 'zh-CN,zh;q=0.9',
                # 'Cache-Control': 'no-cache',
                # 'Connection': 'keep-alive',
                # 'Content-Length': '5190',
                'Content-Type': 'application/x-www-form-urlencoded',
                # 'Cookie': 'sanyousoft=D298DFADFC7726F6A55AF179EFB7C65C; Hm_lvt_3ad329b09e33cc3badcbfc2b7a6e5f4c=1669024735,1669030424,1669080800; Hm_lpvt_3ad329b09e33cc3badcbfc2b7a6e5f4c=1669081054',
                # 'Cookie': 'sanyousoft=7420B02F668963ECF3E4DFBCA0178418;',
                # C2470553DD7AAF0B13A36C2CC8A34D3C
                # 7420B02F668963ECF3E4DFBCA0178418
                'Cookie': f'sanyousoft={soft_cookie};',
                'Host': '58.213.147.230:7001',
                'Origin': 'http://58.213.147.230:7001',
                # 'Pragma': 'no-cache',
                'Referer': 'http://58.213.147.230:7001/Jsjzyxyglpt/faces/public/qyxx5c/fdcqyList.jsp',
                # 'Upgrade-Insecure-Requests': '1',
                'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36',

            }
            # resp = requests.post(
            #     'http://58.213.147.230:7001/Jsjzyxyglpt/faces/public/qyxx5c/fdcqyList.jsp',
            #     data=data
            # )
            # print(resp.text)

            # with open(f'{page}.html', 'w', encoding='utf-8') as f:
            #     f.write('')
            #     f.write(resp.text)
            page += 1
            time.sleep(2)#data=urlencode(data),
            yield scrapy.FormRequest(url=url, formdata=data, headers=headers, dont_filter=True, meta={"countyNum": self.city},callback=self.parse)
            # yield scrapy.Request(url ,method='POST',headers=headers, dont_filter=True,body=json.dumps(data),
            #                      callback=self.parse)
            #  for r in start_requests:
        # for i in range(1,17):
        #     print("爬取到:"+str(i)+"页")
        #             # method='POST',yield scrapy.FormRequest(url=url1, formdata=urlencode(payload), headers=self.headers, dont_filter=True, meta={"countyNum": self.city},callback=self.parse)
        #     yield scrapy.Request(url1+str(i),  headers=self.headers, dont_filter=True, meta={"countyNum": self.city},callback=self.parse)




    # @inline_requests
    def parse(self, response):
        items = MyscrapyRedisItem()

        # a = re.search("", response.text, re.S)#[0].replace("\r", "").replace("\n", "").replace("\t", "")
        markdown = html2text.html2text(response.text, bodywidth=350).strip()#.split("总计")[0].strip()  # 这里单条条是131,140就大于单条了
        result = []
        markdown.split("\n")
        for n, line in enumerate(markdown.split("\n")[:]):
            data = {}
            if n == 0:
                header = [t.strip() for t in line.split('|')[0:]]
            if n > 1:
                values = [t.strip() for t in line.split('|')[0:]]
                for col, value in zip(header, values):
                    data[col] = value
                result.append(data)
        resultdf = pd.DataFrame(result)
        # resultdf["操作"] = resultdf["操作"].apply(lambda x: x.split("(")[1].replace(")", ""))


        #     li_list = li_list + li.split("|")

        result_dict = resultdf.to_dict(orient="records")  # ["详细情况"]
        for item1 in result_dict:
            dict1 = {
                "legalMan":item1["法定代表人"],
                "uniscId": item1["社会统一信用代码"],
                "regionFullname":item1["注册区域"],
                "enterpriseName":item1["企业名称"],
                "districtCode": "--",#region_name_to_Region_code_v2("浙江",li_list[li_list.index('单位地址')+1]),
                "certList1": [
                    {
                        "certId":item1["资质证号"],
                        "pubDate": "--",
                        "endDate": "--",
                        "certType": "房地产开发",
                        "pubDepartment": "江苏省省住房和城乡建设厅",
                        "certName": item1["资质等级"]}
                ]
            }
            items["dict1"]=dict1
            yield items

你可能感兴趣的:(java,servlet,开发语言)