def _reply(self): url = self._get_reply_url() data = { "message": self._msg, "posttime": self._get_args("posttime"), "formhash": self._get_args("formhash"), "sesig": self._get_args("usesig"), "subject": self._get_args("subject"), } # if the self._msg is exist in the page, do nothing if self._exist(): Recorder.info(self, self._user, "reply exist already") return while self._max_retry: try: Recorder.debug(self, self._user, "try to submit comment") r = self._session.post(url, data=data) r.raise_for_status() Recorder.info(self, self._user, "submit succ") break except Exception as e: msg = "_reply failed[{}]".format(self._max_retry) Recorder.warn(self, self._user, msg, e) else: Recorder.error(self, self._user, "run out of reply request retries")
def locate_post_url(self): while True: url = self._locate() if not url: msg = "mismatch and sleep for {}".format(self._interval) Recorder.debug(self, self._user, msg) time.sleep(self._interval) continue msg = "hit the pattern: {}".format(url) Recorder.info(self, self._user, msg) return url