captcha_sid grab response body split -2 url http vk com al_apps php ac

 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
captcha_sid = grab.response.body.split('<!>')[-2]
url = "http://vk.com/al_apps.php?act=show_captcha_box&need_mobile=0&sid={0}" \
"&src=%2Fcaptcha.php%3Fsid%3D{0}&widget=1&widget_width=322".format(captcha_sid)
captcha_grab = grab.clone()
captcha_grab.setup(url=url)
yield Task(grab=captcha_grab)
url = 'http://vk.com/captcha.php?sid=%s' % captcha_sid
captcha_grab.setup(url=url)
captcha_grab = yield Task(grab=captcha_grab)
logger.debug('Submiting captcha')
# Captcha solving
antigate_grab = solver.backend.get_submit_captcha_request(captcha_grab.response.body)
antigate_grab = yield Task(grab=antigate_grab)
logger.debug('Checking solution')
captcha_id = solver.backend.parse_submit_captcha_response(antigate_grab.response)
antigate_grab = solver.backend.get_check_solution_request(captcha_id)
antigate_grab = yield Task(grab=antigate_grab, delay=5)
for x in xrange(5):
try:
solution = solver.backend.parse_check_solution_response(antigate_grab.response)
except SolutionNotReady:
logger.debug('SOLUTION IS NOT READY')
antigate_grab = yield Task(grab=antigate_grab, delay=5)
else:
logger.debug('GOT CAPTCHA SOLUTION: %s' % solution)
post.update({'captcha_sid': captcha_sid, 'captcha_key': solution})
break