inline_task def task_poster self grab task link task link account self

 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
@inline_task
def task_poster(self, grab, task):
link = task.link
account = self.accounts.get()
login, password = account.split(':')
logger = logging.getLogger("%s:%s" % (login, link))
grab = yield self.login_process(grab, login, password)
if not grab.doc.text_search(u'act=logout'):
logger.debug('Can not log in!')
return
else:
logger.debug('log in!')
grab.setup(url=link)
grab = yield Task(grab=grab)
grab = yield self.do_prepare_stuff()
post = self.parse_post(grab)
url = "http://vk.com/al_widget_comments.php"
grab.setup(url=url, post=post)
grab = yield Task(grab=grab)
if grab.doc.text_search(u'<!json>'):
logging.debug('posted')
return
else:
captcha_sid = grab.response.body.split('<!>')[-2]
captcha_grab = yield self.get_captcha_image(grab, captcha_sid)
logger.debug('Submiting captcha')
# Captcha solving
captcha_grab = yield self.captcha_subroutine(self.solver, captcha_grab)
solution = self.solver.backend.parse_check_solution_response(captcha_grab.response)
post.update({'captcha_sid': captcha_sid, 'captcha_key': solution})
logging.debug('Cant post after %s trys' % self.trys)