代码的哪一部分执行在线获取网络钓鱼的工作?

时间:2019-05-13 06:45:32

标签: python machine-learning

我有来自github的这段代码。这基本上是用于使用机器学习检测网络钓鱼URL。我的问题是代码的哪一部分在线扫描URL并显示“这是网络钓鱼URL”?

from flask import Flask,render_template,url_for,request
urls_data = pd.read_csv('urldata.csv')
y = urls_data['label']
url_list = urls_data['url']
vectorizer = TfidfVectorizer()
x = vectorizer.fit_transform(url_list)
x_train,x_test,y_train,y_test = train_test_split(x,y,test_size=0.2,random_state=42)
Logit = LogisticRegression()
Logit.fit(x_train,y_train)
from sklearn.naive_bayes import MultinomialNB
clf = MultinomialNB()
clf.fit(x_train,y_train)
clf.score(x_test,y_test)
if request.method == 'POST':
    phish = request.form['url'] 
    data = [phish]
    vect = vectorizer.transform(data).toarray()
    my_prediction = clf.predict(vect)
return render_template('result.html',prediction = my_prediction)
if __name__ == '__main__':
        app.run(debug = True)

0 个答案:

没有答案