How to use the result.QueryResult function in result

To help you get started, we’ve selected a few result examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sherlock-project / sherlock / sherlock / sherlock.py View on Github external
if error_text is not None:
            result = QueryResult(QueryStatus.UNKNOWN, error_text)
        elif error_type == "message":
            error = net_info.get("errorMsg")
            # Checks if the error message is in the HTML
            if not error in r.text:
                result = QueryResult(QueryStatus.CLAIMED)
            else:
                result = QueryResult(QueryStatus.AVAILABLE)
        elif error_type == "status_code":
            # Checks if the status code of the response is 2XX
            if not r.status_code >= 300 or r.status_code < 200:
                result = QueryResult(QueryStatus.CLAIMED)
            else:
                result = QueryResult(QueryStatus.AVAILABLE)
        elif error_type == "response_url":
            # For this detection method, we have turned off the redirect.
            # So, there is no need to check the response URL: it will always
            # match the request.  Instead, we will ensure that the response
            # code indicates that the request was successful (i.e. no 404, or
            # forward to some odd redirect).
            if 200 <= r.status_code < 300:
                result = QueryResult(QueryStatus.CLAIMED)
            else:
                result = QueryResult(QueryStatus.AVAILABLE)
        else:
            #It should be impossible to ever get here...
            raise ValueError(f"Unknown Error Type '{error_type}' for "
                             f"site '{social_network}'")
github sherlock-project / sherlock / sherlock / sherlock.py View on Github external
response_time = r.elapsed
        except AttributeError:
            response_time = None

        # Attempt to get request information
        try:
            http_status = r.status_code
        except:
            http_status = "?"
        try:
            response_text = r.text.encode(r.encoding)
        except:
            response_text = ""

        if error_text is not None:
            result = QueryResult(QueryStatus.UNKNOWN, error_text)
        elif error_type == "message":
            error = net_info.get("errorMsg")
            # Checks if the error message is in the HTML
            if not error in r.text:
                result = QueryResult(QueryStatus.CLAIMED)
            else:
                result = QueryResult(QueryStatus.AVAILABLE)
        elif error_type == "status_code":
            # Checks if the status code of the response is 2XX
            if not r.status_code >= 300 or r.status_code < 200:
                result = QueryResult(QueryStatus.CLAIMED)
            else:
                result = QueryResult(QueryStatus.AVAILABLE)
        elif error_type == "response_url":
            # For this detection method, we have turned off the redirect.
            # So, there is no need to check the response URL: it will always
github sherlock-project / sherlock / sherlock / sherlock.py View on Github external
headers = {
            'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:55.0) Gecko/20100101 Firefox/55.0',
        }

        if "headers" in net_info:
            # Override/append any extra headers required by a given site.
            headers.update(net_info["headers"])

        # Don't make request if username is invalid for the site
        regex_check = net_info.get("regexCheck")
        if regex_check and re.search(regex_check, username) is None:
            # No need to do the check at the site: this user name is not allowed.
            if not print_found_only:
                print_invalid(social_network, "Illegal Username Format For This Site!", color)

            results_site['status'] = QueryResult(QueryStatus.ILLEGAL)
            results_site["url_user"] = ""
            results_site['http_status'] = ""
            results_site['response_text'] = ""
            results_site['response_time_s'] = ""
        else:
            # URL of user on site (if it exists)
            url = net_info["url"].format(username)
            results_site["url_user"] = url
            url_probe = net_info.get("urlProbe")
            if url_probe is None:
                # Probe URL is normal one seen by people out on the web.
                url_probe = url
            else:
                # There is a special URL for probing existence separate
                # from where the user profile normally can be found.
                url_probe = url_probe.format(username)
github sherlock-project / sherlock / sherlock / sherlock.py View on Github external
except:
            http_status = "?"
        try:
            response_text = r.text.encode(r.encoding)
        except:
            response_text = ""

        if error_text is not None:
            result = QueryResult(QueryStatus.UNKNOWN, error_text)
        elif error_type == "message":
            error = net_info.get("errorMsg")
            # Checks if the error message is in the HTML
            if not error in r.text:
                result = QueryResult(QueryStatus.CLAIMED)
            else:
                result = QueryResult(QueryStatus.AVAILABLE)
        elif error_type == "status_code":
            # Checks if the status code of the response is 2XX
            if not r.status_code >= 300 or r.status_code < 200:
                result = QueryResult(QueryStatus.CLAIMED)
            else:
                result = QueryResult(QueryStatus.AVAILABLE)
        elif error_type == "response_url":
            # For this detection method, we have turned off the redirect.
            # So, there is no need to check the response URL: it will always
            # match the request.  Instead, we will ensure that the response
            # code indicates that the request was successful (i.e. no 404, or
            # forward to some odd redirect).
            if 200 <= r.status_code < 300:
                result = QueryResult(QueryStatus.CLAIMED)
            else:
                result = QueryResult(QueryStatus.AVAILABLE)
github sherlock-project / sherlock / sherlock / sherlock.py View on Github external
except:
            response_text = ""

        if error_text is not None:
            result = QueryResult(QueryStatus.UNKNOWN, error_text)
        elif error_type == "message":
            error = net_info.get("errorMsg")
            # Checks if the error message is in the HTML
            if not error in r.text:
                result = QueryResult(QueryStatus.CLAIMED)
            else:
                result = QueryResult(QueryStatus.AVAILABLE)
        elif error_type == "status_code":
            # Checks if the status code of the response is 2XX
            if not r.status_code >= 300 or r.status_code < 200:
                result = QueryResult(QueryStatus.CLAIMED)
            else:
                result = QueryResult(QueryStatus.AVAILABLE)
        elif error_type == "response_url":
            # For this detection method, we have turned off the redirect.
            # So, there is no need to check the response URL: it will always
            # match the request.  Instead, we will ensure that the response
            # code indicates that the request was successful (i.e. no 404, or
            # forward to some odd redirect).
            if 200 <= r.status_code < 300:
                result = QueryResult(QueryStatus.CLAIMED)
            else:
                result = QueryResult(QueryStatus.AVAILABLE)
        else:
            #It should be impossible to ever get here...
            raise ValueError(f"Unknown Error Type '{error_type}' for "
                             f"site '{social_network}'")