一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

腳本之家,腳本語言編程技術及教程分享平臺!
分類導航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務器之家 - 腳本之家 - Python - Python 通過打碼平臺實現驗證碼的實現

Python 通過打碼平臺實現驗證碼的實現

2021-06-26 00:14shaomine Python

這篇文章主要介紹了Python 通過打碼平臺實現驗證碼的實現,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧

 在爬蟲時,經常遇到登錄需要驗證碼的情況,簡單的驗證碼可以自己解決,復制的驗證碼需要借助機器學習,有一定的難度。還有一個簡單的方案就是采用付費的打碼平臺。

比如r若快(http://www.ruokuai.com/client),還有云打碼平臺(http://www.yundama.com/price.html)

下面以r若快為例介紹打碼平臺的思路:

r若快平臺需要注冊兩個用戶,一個是普通用戶,一個開發者用戶,

Python 通過打碼平臺實現驗證碼的實現

Python 通過打碼平臺實現驗證碼的實現

Python 通過打碼平臺實現驗證碼的實現

Python 通過打碼平臺實現驗證碼的實現

1、首先驗證碼截圖,就是截取網站上登錄頁面的驗證碼圖片并保存到本地

2、調用打碼平臺的接口把驗證碼圖片發送到打碼平臺并獲取到驗證碼結果。

具體代碼如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
# coding:utf-8
 
import requests
from hashlib import md5
 
 
class rclient(object):
 
  def __init__(self, username='shaoks123', password='123456', soft_id='113452', soft_key='c0d07d796c8e470c92a126df60d61794'):
    self.username = username
    # self.password = md5(password).hexdigest()
    self.password = md5(password.encode("utf-8")).hexdigest()
    self.soft_id = soft_id
    self.soft_key = soft_key
    self.base_params = {
      'username': self.username,
      'password': self.password,
      'softid': self.soft_id,
      'softkey': self.soft_key,
    }
    self.headers = {
      'connection': 'keep-alive',
      'expect': '100-continue',
      'user-agent': 'ben',
    }
 
  def rk_create(self, im, im_type, timeout=60):
    """
    im: 圖片字節
    im_type: 題目類型
    """
    params = {
      'typeid': im_type,
      'timeout': timeout,
    }
    params.update(self.base_params)
    files = {'image': ('a.jpg', im)}
    r = requests.post('http://api.ruokuai.com/create.json', data=params, files=files, headers=self.headers)
    return r.json()
 
  def rk_report_error(self, im_id):
    """
    im_id:報錯題目的id
    """
    params = {
      'id': im_id,
    }
    params.update(self.base_params)
    r = requests.post('http://api.ruokuai.com/reporterror.json', data=params, headers=self.headers)
    return r.json()
 
  def test(self,imagefile,im_type=1030):
    # im = open('e:\python36_crawl\veriycode\code\code_823.png', 'rb').read()
    im = open(imagefile, 'rb').read()
    result = self.rk_create(im, im_type)
    print(result['result'])
    return result['result']
 
 
# if __name__ == '__main__':
#   rc = rclient()
#   im = open('e:\python36_crawl\veriycode\code\code_823.png', 'rb').read()
#   result = rc.rk_create(im, 1030)
#   print(result['result'])

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。

原文鏈接:https://www.cnblogs.com/shaosks/p/9816106.html

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 乌克兰17一18处交 | 日本一卡二卡3卡四卡无卡网址 | 恩不要好大好硬好爽3p | sedog在线长片 | 久久99亚洲热最新地址获取 | 99久久无色码中文字幕 | 2020国产精品视频 | 亚洲女同在线观看 | 暖暖视频免费观看视频中国.韩剧 | 亚洲精品一二三四区 | 国产小视频在线免费 | 欧美日本一本线在线观看 | 国产日韩精品一区二区 | 国产一二在线观看视频网站 | 男人天堂中文字幕 | 99精品视频在线观看 | 青青国产成人久久激情91麻豆 | 奇米影视在线观看 | 久久www免费人成_看片高清 | 成人私人影院在线观看网址 | japanese乱子mate| 亚洲天堂伦理 | 青草热久精品视频在线观看 | 99在线视频精品费观看视 | 九九精品免费视频 | 亚洲国产精品自产在线播放 | 欧美草逼视频 | 久久精品观看 | 欧美午夜视频一区二区 | 视频在线播放 | chinesespank调教| 欧美一级片免费在线观看 | 欧美一级视频在线观看 | 欧美帅老头oldmangay | 青青草国产青春综合久久 | 国产麻豆91欧美一区二区 | 四虎永久免费地址 | 公妇乱淫在线播放免费观看 | 蜜桃视频一区二区 | 娇妻与公陈峰姚瑶小说在线阅读 | 精品国产福利在线 |