def _test_whatsapp_web(self, url): try: response = yield self.doRequest(url, 'GET') except Exception as exc: failure_string = failureToString(defer.failure.Failure(exc)) log.err("Failed to connect to whatsapp web %s" % failure_string) self.report['whatsapp_web_failure'] = failure_string self.report['whatsapp_web_status'] = 'blocked' defer.returnValue(None) title = extractTitle(response.body).strip() if title != "WhatsApp Web": self.report['whatsapp_web_status'] = 'blocked'
def _test_telegram_web(self, url): try: response = yield self.doRequest(url, 'GET') except Exception as exc: failure_string = failureToString(defer.failure.Failure(exc)) log.err("Failed to connect to telegram web %s" % failure_string) self.report['telegram_web_failure'] = failure_string self.report['telegram_web_status'] = 'blocked' defer.returnValue(None) title = extractTitle(response.body).strip() if title != "Telegram Web": self.report['telegram_web_status'] = 'blocked'
def compare_titles(self, experiment_http_response): experiment_title = extractTitle(experiment_http_response.body).strip() control_title = self.control["http_request"]["title"].strip() control_words = control_title.split(" ") for idx, exp_word in enumerate(experiment_title.split(" ")): # We don't consider to match words that are shorter than 5 # characters (5 is the average word length for english) if len(exp_word) < 5: continue try: return control_words[idx].lower() == exp_word.lower() except IndexError: return False
def compare_titles(self, experiment_http_response): experiment_title = extractTitle(experiment_http_response.body).strip() control_title = self.control['http_request']['title'].strip() control_words = control_title.split(' ') for idx, exp_word in enumerate(experiment_title.split(' ')): # We don't consider to match words that are shorter than 5 # characters (5 is the average word length for english) if len(exp_word) < 5: continue try: return control_words[idx].lower() == exp_word.lower() except IndexError: return False