Python whois.query() Examples
The following are 5
code examples of whois.query().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
whois
, or try the search function
.
Example #1
Source File: action.py From insightconnect-plugins with MIT License | 6 votes |
def run(self, params={}): domain = str(params.get(Input.DOMAIN)) # Comes in as unicode - whois library has assert for type on str self.logger.info("Getting whois information for %s" % domain) if not self.is_valid_domain(domain=domain): raise PluginException(cause="Invalid domain as input.", assistance="Ensure the domain is not prefixed with a protocol.") try: lookup_results = whois.query(domain, ignore_returncode=1) # ignore_returncode required for plugin except Exception as e: self.logger.error("Error occurred: %s" % e) raise else: serializable_results = lookup_results.get_json_serializable() serializable_results = insightconnect_plugin_runtime.helper.clean_dict(serializable_results) return serializable_results
Example #2
Source File: whois.py From og-miner with MIT License | 6 votes |
def process(self, profile, state, vertex): if 'type' not in vertex: return { 'error' : "No vertex type defined!" } properties = dict() neighbors = list() if vertex['type'] == "domain": try: lookup = whois.query(vertex['id']) if lookup is not None: for k, v in lookup.__dict__.items(): if isinstance(v, set): properties[k] = list(v) else: properties[k] = v except Exception as e: print("Exception: {0}".format(e)) return { "properties": properties, "neighbors" : neighbors }
Example #3
Source File: Whoiser.py From squatm3 with GNU General Public License v3.0 | 5 votes |
def get_info(self, domain): self.domain = domain w = whois.query(self.domain) if w is not None: self.expiration_date = "" self.creation_date = "" if w.expiration_date is not None: self.expiration_date = str(w.expiration_date.isoformat()) if w.creation_date is not None: self.creation_date = str(w.creation_date.isoformat())
Example #4
Source File: lookup.py From metadoc with MIT License | 5 votes |
def whois_date_registered(domain): try: query = whois.query(domain) # silently fails in corporate env, vocally fails behind proxy except Exception as e: query = None pass # if query.creation_date == "before aug-1996": query.creation_date = datetime.datetime(1996) # .co.uk edge case # elif type(query.creation_date) is not "date": query = None return query.creation_date if query else None
Example #5
Source File: features_extraction.py From Malicious-Web-Content-Detection-Using-Machine-Learning with MIT License | 4 votes |
def main(url): with open(LOCALHOST_PATH + DIRECTORY_NAME + '/markup.txt', 'r') as file: soup_string = file.read() soup = BeautifulSoup(soup_string, 'html.parser') status = [] hostname = get_hostname_from_url(url) status.append(having_ip_address(url)) status.append(url_length(url)) status.append(shortening_service(url)) status.append(having_at_symbol(url)) status.append(double_slash_redirecting(url)) status.append(prefix_suffix(hostname)) status.append(having_sub_domain(url)) dns = 1 try: domain = whois.query(hostname) except: dns = -1 status.append(-1 if dns == -1 else domain_registration_length(domain)) status.append(favicon(url, soup, hostname)) status.append(https_token(url)) status.append(request_url(url, soup, hostname)) status.append(url_of_anchor(url, soup, hostname)) status.append(links_in_tags(url, soup, hostname)) status.append(sfh(url, soup, hostname)) status.append(submitting_to_email(soup)) status.append(-1 if dns == -1 else abnormal_url(domain, url)) status.append(i_frame(soup)) status.append(-1 if dns == -1 else age_of_domain(domain)) status.append(dns) status.append(web_traffic(soup)) status.append(google_index(url)) status.append(statistical_report(url, hostname)) print('\n1. Having IP address\n2. URL Length\n3. URL Shortening service\n4. Having @ symbol\n' '5. Having double slash\n6. Having dash symbol(Prefix Suffix)\n7. Having multiple subdomains\n' '8. SSL Final State\n8. Domain Registration Length\n9. Favicon\n10. HTTP or HTTPS token in domain name\n' '11. Request URL\n12. URL of Anchor\n13. Links in tags\n14. SFH\n15. Submitting to email\n16. Abnormal URL\n' '17. IFrame\n18. Age of Domain\n19. DNS Record\n20. Web Traffic\n21. Google Index\n22. Statistical Reports\n') print(status) return status # Use the below two lines if features_extraction.py is being run as a standalone file. If you are running this file as # a part of the workflow pipeline starting with the chrome extension, comment out these two lines. # if __name__ == "__main__": # if len(sys.argv) != 2: # print("Please use the following format for the command - `python2 features_extraction.py <url-to-be-tested>`") # exit(0) # main(sys.argv[1])