Quantcast
Viewing all articles
Browse latest Browse all 46

AttributeError: module 'whois' has no attribute 'whois'

I am running my ML code and getting this error-

    Enter website name=> www.google.comTraceback (most recent call last):  File "Dphishing.py", line 12, in <module>    p2.category2(website)  File "C:\xampp\htdocs\Detect_Phishing_Website\p2.py", line 8, in category2    page = whois.whois(website)AttributeError: module 'whois' has no attribute 'whois'

My code is:

# -*- coding: utf-8 -*-import p1import p2import p3import p4import pandas as pd#import numpy as npwebsite = str(input("Enter website name=> "))p1.category1(website)p2.category2(website)p3.category3(website)p4.category4(website)read = pd.read_csv(r'C:\Users\Anushree\Desktop\college\4th year project\Detect_Phishing_Website\phishing5.txt',header = None,sep = ',')read = read.iloc[:,:-1].valuesdataset = pd.read_csv(r'C:\Users\Anushree\Desktop\college\4th year project\Detect_Phishing_Website\Training Dataset1.csv')X = dataset.iloc[:,:-1].values  y = dataset.iloc[:,-1].valuesfrom sklearn.model_selection import train_test_splitX_train,X_test,y_train,y_test = train_test_split(X,y,test_size = 0.2,random_state = 1001)from sklearn.ensemble import RandomForestRegressorregressor = RandomForestRegressor(n_estimators = 10,criterion = "mse",random_state = 2)regressor.fit(X_train,y_train)                             y_pred = regressor.predict(X_test)from sklearn.model_selection import cross_val_scoreaccuracy = cross_val_score(estimator = regressor,X=X_train,y=y_train,cv = 5)accuracy.mean()accuracy.std()Detect_phishing_website = regressor.predict(read)if Detect_phishing_website == 1:    print("legitimate website")elif Detect_phishing_website == 0:    print ('suspicious website')else:    print('phishing website')

The code of file p2.py is:

import reimport whoisdef category2(website):    file_obj = open(r'C:\Users\Anushree\Desktop\college\4th year project\Detect_Phishing_Website\phishing5.txt','a')    #8 Domain Registration Length    page = whois.whois(website)    if type(page.expiration_date) == list:        domain_reg_len = (page.expiration_date[0] - page.creation_date[0]).days    else:        domain_reg_len = (page.expiration_date - page.creation_date).days    #print domain_reg_len    if domain_reg_len <= 365:        file_obj.write('-1,')    else:        file_obj.write('1,')    #9 Using Non-Standard Port     match_port = re.search(':[//]+[a-z]+.[a-z0-9A-Z]+.[a-zA-Z]+:([0-9#]*)',website)    if match_port:        print (match_port.group())        if match_port.group(1) == '#':#represent multiple ports are active on url            file_obj.write('-1,')        else:            file_obj.write('1,')    else:        file_obj.write('1,')    file_obj.close()

I have already tried uninstalling whois and then reinstalling python-whois using the command pip install python-whois. But that hasn't helped with the error.

How can I understand what is going wrong, and how I can correct it?


Viewing all articles
Browse latest Browse all 46

Trending Articles