我的程序是一个基于Python的Web爬虫程序,它通过Linux发行版上的终端命令(使用Ubuntu 14)提取数据。 自从我为它实现了GT3 + GUI后,我收到了以下错误:
/usr/bin/python3.4 /home/dipeshwar/Documents/WebsiteScanner/main.py Traceback(最近一次调用最后一次):文件
" /home/dipeshwar/Documents/WebsiteScanner/main.py" ;,第81行,在 button_clicked gather_info(self.name,self.url)File" /home/dipeshwar/Documents/WebsiteScanner/main.py" ;,第44行,in gather_info domain = get_domain_name(url)File" /home/dipeshwar/Documents/WebsiteScanner/domain.py" ;,第16行,in get_domain_name domain = get_tld(url)File" /usr/local/lib/python3.4/dist-packages/tld/utils.py" ;,第161行,在 get_tld url = url.lower()属性错误:'条目'对象没有属性' lower' 这是我的代码。你能告诉我为什么它给我这个错误吗? 在get_doman_name函数中,我只是使用&#t; tld' Python中的模块以获得顶级域名。
此致
from gi.repository import Gtk
# import statement for GUI
from general import *
from whois import *
from domain import *
from ipadd import *
from nmap import *
from robots_txt import *
# these import statements get all the variables from other modules of this program
ROOT_DIR = 'Output'
create_dir(ROOT_DIR)
# Checks if directory is created or not, if not, the program creates it
def create_report(name, url, domain, ipadd, nmap, robots_txt, whois): # or def create_report(name, full_url, domain, ipadd, nmap, robots_txt, whois): ?
project_dir = ROOT_DIR + '/' + name
create_dir(project_dir)
write_file(project_dir + '/full_url.txt', url) # or full_url ?
write_file(project_dir + '/domain.txt', domain)
write_file(project_dir + '/ipadd.txt', ipadd)
write_file(project_dir + '/nmap.txt', nmap)
write_file(project_dir + '/robots_txt.txt', robots_txt)
write_file(project_dir + '/whois.txt', whois)
def gather_info(name, url):
domain = get_domain_name(url)
ipadd = get_ip_address(url)
nmap = get_nmap(ipadd)
robots_txt = get_robots_txt(url)
whois = get_whois(url)
create_report(name, url, domain, ipadd, nmap, robots_txt, whois)
class MainWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="Reconnaissance Web-Scanner")
self.set_border_width(30)
self.set_size_request(300, 200)
# Layout of window
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=8)
self.add(vbox)
# Inputs
self.name = Gtk.Entry()
self.name.set_text("Enter name of website here:")
vbox.pack_start(self.name, True, True, 0)
self.url = Gtk.Entry()
self.url.set_text("Enter URL of website here:")
vbox.pack_start(self.url, True, True, 0)
# Button
self.button = Gtk.Button(label="Scan Website")
self.button.connect("clicked", self.button_clicked)
vbox.pack_start(self.button, True, True, 0)
# when user clicks the button
def button_clicked(self, widget):
gather_info(self.name, self.url)
# put exec code here
答案 0 :(得分:0)
self.name
和self.url
都是Gtk.Entry
而不是字符串。因此,您必须将代码更改为:
def button_clicked(self, widget):
gather_info(self.name.get_text(), self.url.get_text())