我是python tkinter开发的新手。我制作了使用请求获取来扫描网址列表的工具,当我尝试对其进行过滤并插入文本框时,它显示没有响应,然后经过很多时间,它插入了文本框,然后出现了问题
我厌倦了很多方法,看了python tkinter教程,但没有找到教程
import requests
from tkinter import *
from tkinter import filedialog
from bs4 import BeautifulSoup
from multiprocessing import Pool
from multiprocessing.dummy import Pool as ThreadPool
from time import time as timer
from random import sample as rand
from Queue import Queue
from platform import system
from urlparse import urlparse
from optparse import OptionParser
from colorama import Fore
from colorama import Style
from pprint import pprint
from colorama import init
init(autoreset=True)
####### Colors ######
fr = Fore.RED
fc = Fore.CYAN
fw = Fore.WHITE
fg = Fore.GREEN
sd = Style.DIM
sn = Style.NORMAL
sb = Style.BRIGHT
#######################
RaiC0d3r = Tk()
RaiC0d3r.title("CMS Detector V.1 ")
RaiC0d3r.geometry("1920x1080")
def cmsdetector():
ipv4check = requests.get('http://ipv4.icanhazip.com').text
licensed = requests.get('https://raw.githubusercontent.com/raic0d3r/Private-Bot/master/licensed').text
if ipv4check in licensed:
try:
Get_list = filedialog.askopenfilename(title = "Select file",filetypes = (("txt files","*.txt"),("all files","*.*")))
with open(Get_list, 'r') as zz:
Readlist = zz.read().splitlines()
except IOError:
print '--------------------------------------------'
print ' [-] List Not Found in Directory!'
sys.exit()
thread = []
for url in Readlist:
url = url
t = threading.Thread(target=sitebul, args=(url, ''))
t.daemon = True
t.start()
thread.append(t)
time.sleep(0.1)
for j in thread:
j.join()
else:
PrintWpData.insert(END, 'Ask Permission From RaiC0d3r')
PrintJMData.insert(END, 'Ask Permission From RaiC0d3r')
PrintDpData.insert(END, 'Ask Permission From RaiC0d3r')
PrintPsData.insert(END, 'Ask Permission From RaiC0d3r')
PrintOsCData.insert(END, 'Ask Permission From RaiC0d3r')
PrintZenData.insert(END, 'Ask Permission From RaiC0d3r')
PrintunkData.insert(END, 'Ask Permission From RaiC0d3r')
# concurrent = 75
# q = Queue(concurrent * 2)
# for i in range(concurrent):
# t = threading.Thread(target=sitebul)
# t.daemon = True
# t.start()
# try:
# for url in open(Get_list):
# q.put(url.strip())
# q.join()
# except:
# pass
def sitebul(url, x):
try:
# while True:
# url = self.q.get()
# if url.startswith('http://'):
# url = url.replace('http://', '')
# elif url.startswith("https://"):
# url = url.replace('https://', '')
# else:
# pass
# try:
Checktwo = requests.get('http://'+url, timeout=5)
CheckOsc2 = requests.get('http://'+url + '/admin/login.php', timeout=5)
Checktree = requests.get('http://'+url + '/application/configs/application.ini', timeout=5)
if "/wp-content/" in Checktwo.content:
PrintWpData.insert(END, url+'\n')
# PrintWpData.see(END, url+'\n')
# PrintWpData.update_idletasks(END, url+'\n')
elif requests.get('http://'+url + "/administrator/manifests/files/joomla.xml").status_code == 200:
PrintJMData.insert(END, url+'\n')
elif "/sites/default/" in Checktwo.content:
PrintDpData.insert(END, url+'\n')
elif "prestashop" in Checktwo.content:
PrintPsData.insert(END, url+'\n')
elif "osCommerce" in CheckOsc2.content:
PrintOsCData.insert(END, url+'\n')
elif "APPLICATION_PATH" in Checktree.content:
PrintZenData.insert(END, url+'\n')
else:
PrintunkData.insert(END, url+'\n')
# except:
# pass
except:
pass
domain = Label(RaiC0d3r, text="Domain :")
domain.grid(row=2,column=0)
domainEnt = Button(RaiC0d3r , text="Domain List",bg="purple" , fg="white" ,command=cmsdetector)
domainEnt.grid(row=2 ,column=4)
#progress = Progressbar(RaiC0d3r, orient=HORIZONTAL,length=200, mode='determinate')
#progress.grid(row=2,column=3)
#ProxyPrint = Label(RaiC0d3r, text="Proxy :")
#ProxyPrint.grid(row=0,column=0)
#EntProxy = Entry(RaiC0d3r)
#EntProxy.grid(row=0,column=1)
#domainEnt = Entry(RaiC0d3r)
#domainEnt.grid(row=0,column=1)
#Bts = Button(RaiC0d3r , text="Get",bg="purple" , fg="white" ,command=openfile)
#Bts.grid(row=0 ,column=5)
Space = Label(RaiC0d3r, text=" ")
Space.grid(row=2,column=2)
wp = Label(RaiC0d3r, text="Wordpress ")
wp.grid(row=4,column=1)
joomla = Label(RaiC0d3r, text="Joomla ")
joomla.grid(row=4,column=2)
drupla = Label(RaiC0d3r, text="Drupal ")
drupla.grid(row=4,column=3)
pshop = Label(RaiC0d3r, text="PrestaShop ")
pshop.grid(row=4,column=4)
oSCmr = Label(RaiC0d3r, text="osCommerce ")
oSCmr.grid(row=4,column=5)
zen = Label(RaiC0d3r, text="Zen ")
zen.grid(row=4,column=6)
unk = Label(RaiC0d3r, text="Unknown ")
unk.grid(row=4,column=7)
URL = Label(RaiC0d3r, text="CMS :")
URL.grid(row=5,column=0)
PrintWpData = Text(RaiC0d3r , width=30 , height=40,wrap=WORD)
PrintWpData.grid(row=5 , column=1)
PrintJMData = Text(RaiC0d3r , width=30 , height=40,wrap=WORD)
PrintJMData.grid(row=5 , column=2)
PrintDpData = Text(RaiC0d3r , width=30 , height=40,wrap=WORD)
PrintDpData.grid(row=5 , column=3)
PrintPsData = Text(RaiC0d3r , width=30 , height=40,wrap=WORD)
PrintPsData.grid(row=5 , column=4)
PrintOsCData = Text(RaiC0d3r , width=30 , height=40,wrap=WORD)
PrintOsCData.grid(row=5 , column=5)
PrintZenData = Text(RaiC0d3r , width=30 , height=40,wrap=WORD)
PrintZenData.grid(row=5 , column=6)
PrintunkData = Text(RaiC0d3r , width=30 , height=40,wrap=WORD)
PrintunkData.grid(row=5 , column=7)
Space = Label(RaiC0d3r, text=" ")
Space.grid(row=6,column=2)
Space = Label(RaiC0d3r, text=" ")
Space.grid(row=7,column=2)
copyright = Label(RaiC0d3r, text="CMS Detector BY RaiC0d3r")
copyright.grid(row=8,column=4)
def selectall(event):
event.widget.tag_add("sel","1.0","end")
RaiC0d3r.bind_class("Text","<Control-a>", selectall)
```RaiC0d3r.mainloop()
result show on textbox but take time and show no responding https://prnt.sc/ovs07r
答案 0 :(得分:0)
我正在Windows10下运行Python 3.6.5,因此可能存在一些差异。
我自由地将代码缩减为可控制的大小,然后我插入了一些当前时间的图片,以了解时间的消耗情况。
import requests
from tkinter import *
from datetime import datetime
def cmsdetector():
print(datetime.now())
ipv4check = requests.get('http://ipv4.icanhazip.com').text
print(datetime.now())
licensed = requests.get('https://raw.githubusercontent.com/raic0d3r/Private-Bot/master/licensed').text
print(datetime.now())
if ipv4check in licensed:
PrintWpData.insert(END, 'ipv4check passed')
else:
PrintWpData.insert(END, 'Ask Permission From RaiC0d3r')
print(datetime.now())
RaiC0d3r = Tk()
domainEnt = Button(RaiC0d3r , text="Domain List", command=cmsdetector)
domainEnt.grid(row=2 ,column=1, pady=(10,0))
PrintWpData = Text(RaiC0d3r , width=30, height=10, wrap=WORD)
PrintWpData.grid(row=5, column=1, padx=10, pady=10)
当我单击域列表按钮时,输出为:
2019-08-22 03:09:08.418965
2019-08-22 03:09:08.496544
2019-08-22 03:09:08.922195
2019-08-22 03:09:08.922195
您可以在其中看到requests.get()
调用最多的时间。因此,我猜测您要查询的服务器上的负载可能会有所不同,有时可能会“很长一段时间”。从我可以看到,tkinter没有任何问题。