保存新浪微博授权登录验证码图片供机器学习 非机器学习方法的实现 近似度量化比较

 

 

 

open('mypng.png','wb').write((requests.get(url)._content))


HTTPSConnectionPool(host='login.sina.com.cn', port=443): Max retries exceeded with url: /cgi/pin.php?r=48137058&s=0&p=tc-e8d1b4ea6beb93e9c1f67504c40e2c59c10e (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x00000214EE586198>: Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。',))
-----------------
cnn/49167360sina_com_cn_cgi_pin.php.png
cnn/80874485sina_com_cn_cgi_pin.php.png
cnn/85921430sina_com_cn_cgi_pin.php.png
cnn/57878857sina_com_cn_cgi_pin.php.png
cnn/87437683sina_com_cn_cgi_pin.php.png
cnn/42701834sina_com_cn_cgi_pin.php.png
cnn/14463780sina_com_cn_cgi_pin.php.png
cnn/41911142sina_com_cn_cgi_pin.php.png
cnn/51278293sina_com_cn_cgi_pin.php.png
cnn/89302902sina_com_cn_cgi_pin.php.png
cnn/23213296sina_com_cn_cgi_pin.php.png
HTTPSConnectionPool(host='login.sina.com.cn', port=443): Max retries exceeded with url: /cgi/pin.php?r=48137058&s=0&p=tc-e8d1b4ea6beb93e9c1f67504c40e2c59c10e (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x00000214EE550E10>: Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。',))
-----------------
cnn/82880039sina_com_cn_cgi_pin.php.png
cnn/16721523sina_com_cn_cgi_pin.php.png
cnn/29145537sina_com_cn_cgi_pin.php.png

 

 

 

 

import random
import requests
from time import sleep

useed_int_l = []
url = 'https://login.sina.com.cn/cgi/pin.php?r=12341234&s=0&p=tc-e8d1b4ea6beb93e9c1f67504c40e2c59c10e'
img_dir = 'cnn/'
while True:
i = random.randrange(10 ** 7, 10 ** 8)
if i not in useed_int_l:
s = str(i)
url = url.replace('12341234', s)
cnn = '%s%s%s' % (img_dir, s, 'sina_com_cn_cgi_pin.php.png')
bytes = 0
try:
bytes = requests.get(url)._content
except Exception as e:
print(e)
sleep(1)

if bytes != 0:
with open(cnn, 'wb')as f:
f.write(bytes)
print(cnn)
else:
print('-----------------')

特征提取

放大后观察,干扰曲线为实心线,而待识别字符为虚心

 

 

 

 




可垂直于宽切割

 

字体唯一,1-9-0a_zA_Z,只是旋转角度大致为-90-+90

字符个数唯一,为5

 

 

思路:

切割出5个字符,在-90-+90间旋转,与标准字符做相似度比较,量化,取最近的为识别结果,不考虑干扰线的影响

 

posted @ 2018-01-04 15:01  papering  阅读(806)  评论(0编辑  收藏  举报