本文整理汇总了Python中Solver.Solver.get_result方法的典型用法代码示例。如果您正苦于以下问题:Python Solver.get_result方法的具体用法?Python Solver.get_result怎么用?Python Solver.get_result使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Solver.Solver
的用法示例。
在下文中一共展示了Solver.get_result方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from Solver import Solver [as 别名]
# 或者: from Solver.Solver import get_result [as 别名]
def run(self):
while True:
html = self.opener.open(captcha_url).read().decode()
captcha_img_url = host + pq(html)("#captcha_image").attr("src")
captcha_img = self.opener.open(captcha_img_url).read()
try:
solver = Solver(Image.open(BytesIO(captcha_img)), captcha_length)
result = solver.get_result()
if len(solver.char_areas) != captcha_length:
raise IndexError()
except IndexError:
self.queue.put(
(Image.open(BytesIO(captcha_img)), Image.open(BytesIO(captcha_img)), "------", False, True))
continue
payload = {
"do": "contact",
"ct_name": "",
"ct_email": "",
"ct_URL": "",
"ct_message": "",
"ct_captcha": result
}
resp = self.opener.open(captcha_url, urlencode(payload).encode()).read().decode()
print("put!")
img_data = {
'pixels': solver.captcha.tobytes(),
'size': solver.captcha.size,
'mode': solver.captcha.mode,
}
if "captcha was correct" in resp:
self.queue.put((Image.open(BytesIO(captcha_img)), img_data, result, True, False))
print('Corr')
else:
self.queue.put((Image.open(BytesIO(captcha_img)), img_data, result, False, False))
print('Wong')
示例2: run
# 需要导入模块: from Solver import Solver [as 别名]
# 或者: from Solver.Solver import get_result [as 别名]
def run(self):
while True:
buffer = BytesIO(urlopen(captcha_url).read())
solver = Solver(Image.open(buffer), captcha_length)
while len(solver.char_areas) != captcha_length:
buffer = BytesIO(urlopen(captcha_url).read())
solver = Solver(Image.open(buffer), captcha_length)
buffer.seek(0)
captcha_result = solver.get_result()
CaptchaGatherThread.captchas.put({"captcha": Image.open(buffer), "solver": solver, "guess": captcha_result})
示例3: run
# 需要导入模块: from Solver import Solver [as 别名]
# 或者: from Solver.Solver import get_result [as 别名]
def run(self):
while True:
solver = None
while solver is None or len(solver.char_areas) != captcha_length:
rep = urlopen(captcha_url)
answer = rep.info()['x-captcha-code']
print(answer)
buffer = BytesIO(rep.read())
solver = Solver(Image.open(buffer), captcha_length)
buffer.seek(0)
captcha_result = solver.get_result()
CaptchaGatherThread.captchas.put({"captcha": Image.open(buffer), "solver": solver, "guess": captcha_result, "answer": answer})
print('Put')
示例4: run
# 需要导入模块: from Solver import Solver [as 别名]
# 或者: from Solver.Solver import get_result [as 别名]
def run(self):
while True:
buffer = BytesIO(self.opener.open(captcha_url).read())
try:
solver = Solver(Image.open(buffer), captcha_length)
except Exception as e:
print("Rate limit exceeded: ", e)
return
while len(solver.char_areas) != captcha_length:
buffer = BytesIO(self.opener.open(captcha_url).read())
solver = Solver(Image.open(buffer), captcha_length)
buffer.seek(0)
captcha_result = solver.get_result()
CaptchaGatherThread.captchas.put({"captcha": Image.open(buffer), "solver": solver, "guess": captcha_result})