Exemplo n.º 1
0
    def process_unavailable(self, response):
        if response.status_code != 410:
            return BaseService.process_unavailable(self, response)

        match = re.search(r'was forwarding to: <BR> <font color=red>(.*)</font>', response.text)

        if not match:
            if re.search(r'This shortURL address was REMOVED for SPAMMING', response.text):
                return URLStatus.unavailable, None, None

        if not match and 'REMOVED FOR SPAMMING' in response.text:
            return URLStatus.unavailable, None, None

        if not match:
            raise UnexpectedNoResult(
                "Could not find target URL on blocked page for {0}"
                .format(self.current_shortcode))

        url = html_unescape(match.group(1))

        return URLStatus.ok, url, response.encoding