• <fieldset id="82iqi"></fieldset>
    <tfoot id="82iqi"><input id="82iqi"></input></tfoot>
  • 
    <abbr id="82iqi"></abbr><strike id="82iqi"></strike>
  • 如何利用requests調用OCRKing接口?

    如何利用requests調用OCRKing接口?

    前幾天看到一個PIL制作驗證碼的文字這幾天想怎么學習接口破解簡單驗證碼

    OcrKing 對于驗證碼的效果還行,雖然不如uu云 但是對于免費的來說夠用了,只是學習而已

    apikey建議自己獲取一個反正也是免費的,異地調用會被封號==

    import requests,re

    #apikey 發郵件給ok@ocrking.com主題必須填寫 apiKey 內容隨便填點 就ok自動獲取

    key='馬賽克'

    url='http://api.ocrking.com/server.html'

    url2='http://lab.ocrking.com/ok.html'

    #接收文件類型為xml所以header.Acceept要正確否則報錯

    headers = { "Accept":"text/html,application/xhtml+xml,application/xml;",

    "Accept-Encoding":"gzip",

    "Accept-Language":"zh-CN,zh;q=0.8",

    "Referer":"http://m.example.com/",

    "User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36"

    }

    img=open(r'C:\Users\sunqi\Desktop\testcode\54.png','rb')

    set1={

    'url':'',

    'service':'OcrKingForCaptcha',#ocr類型

    'language':'eng',

    'charset':'7',#驗證碼類型

    'apiKey':key,

    'type':'http://m.unknown.com' #預處理

    }

    file={'ocrfile':('123.png',img.read(),'application/octet-stream')}

    r=requests.post(url2,data=set1,files=file,headers=headers)

    s=r.text

    result=re.findall(r'(.*)',s)[0]

    status=re.findall(r'(.*)',s)[0]

    print(status,result)