简体   繁体   中英

It's my first time trying tkinter and I can't get over this error. Can someone tell me what's wrong with it and suggest a fix?

It's my first time trying tkinter and I can't get over this error. Can someone tell me what's wrong with it and suggest a fix?

I get TypeError: repip() takes exactly 1 argument (0 given) error.

import Tkinter as tk
from Tkinter import *
import ttk
import tkFileDialog as filedialog
import os
import requests
from multiprocessing import Pool
from multiprocessing.dummy import Pool as ThreadPool
from re import findall as reg
import shutil

main_window = tk.Tk()
main_window.title('sample 1')
main_window.resizable(False, False)
main_window.geometry("390x400")

def open_file(file):
   file = filedialog.askopenfile(mode='r', filetypes=[('text files', '*.txt')])
   file = open(file, 'r').read().splitlines()
   Thread = 50
   pool = ThreadPool(int(Thread))
   pool.map(repip, file)
   pool.close()
   pool.join()
   if file:
      filepath = os.path.abspath(file.name)
      entry1.insert(END, filepath)


def repip(file):
    try:
        grab = requests.get('https://tools.webservertalk.com/?tool=reverseip&host='+file).content
        if 'Domain / IP:' in grab:
            regx = reg('<td class="text-left">(.*?)<', grab)
            for ckk in regx:
                mek = ckk.replace("Domain","")
                listbox.insert("{}[Grabbed] {}".format(Fore.YELLOW, str(mek)))
                open('grabbed.txt', 'a').write('http://'+mek+'\n')
            else:
                print "{}[Operation timed out] {}".format(Fore.RED, str(url))
    except:
        pass


label = Label(main_window, text="Select domain list")
label.grid(row=0, sticky=W, pady=3, padx=3)

entry1 = tk.Entry(main_window, width=50)
entry1.grid(row=1, sticky=W, pady=3, padx=3)

ttk.Button(main_window, text="Browse", command=open_file).grid(row=1, column=1, sticky=W, pady=2)
ttk.Button(main_window, text="Start", command=repip).grid(row=2, column=1, sticky=W, pady=2)

listbox = Listbox(main_window, width=50, height=20)
listbox.place(x=2, y=60)

scrollbar = Scrollbar(main_window, orient="vertical", command=listbox.yview)
scrollbar.place(x=290, y=60, height=323)
listbox.config(yscrollcommand=scrollbar.set)

tk.mainloop()

The second argument for pool.map is an iterable, like a list. Wrap around the file in square brackets and it should work:

pool.map(repip, [file])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM