52 lines
1.7 KiB
Python
52 lines
1.7 KiB
Python
|
import tkinter as tk
|
||
|
from tkinter import messagebox
|
||
|
|
||
|
class GoogleSearchGenerator:
|
||
|
def __init__(self, root):
|
||
|
self.root = root
|
||
|
self.root.title("谷歌搜索语法生成器")
|
||
|
|
||
|
self.search_query = tk.StringVar()
|
||
|
self.search_query.set("")
|
||
|
|
||
|
self.query_label = tk.Label(root, text="生成的搜索语句:")
|
||
|
self.query_label.pack(pady=5)
|
||
|
|
||
|
self.query_entry = tk.Entry(root, textvariable=self.search_query, width=50)
|
||
|
self.query_entry.pack(pady=5)
|
||
|
|
||
|
self.buttons_frame = tk.Frame(root)
|
||
|
self.buttons_frame.pack(pady=10)
|
||
|
|
||
|
self.create_buttons()
|
||
|
|
||
|
def create_buttons(self):
|
||
|
buttons = [
|
||
|
("正文关键词", "intext:"),
|
||
|
("链接关键词", "inurl:"),
|
||
|
("标题关键字", "intitle:"),
|
||
|
("指定域名", "site:"),
|
||
|
("文件类型:", "filetype:"),
|
||
|
("相关链接:", "link:"),
|
||
|
("查看网页缓存", "cache:"),
|
||
|
("查看站点信息", "info:"),
|
||
|
("搜索相关信息:", "related:"),
|
||
|
]
|
||
|
|
||
|
for text, param in buttons:
|
||
|
button = tk.Button(self.buttons_frame, text=text, command=lambda p=param: self.add_parameter(p))
|
||
|
button.pack(side=tk.LEFT, padx=5)
|
||
|
|
||
|
def add_parameter(self, param):
|
||
|
current_query = self.search_query.get()
|
||
|
if current_query:
|
||
|
new_query = f"{current_query} {param}"
|
||
|
else:
|
||
|
new_query = param
|
||
|
self.search_query.set(new_query)
|
||
|
# messagebox.showinfo("提示", f"已添加参数: {param}")
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
root = tk.Tk()
|
||
|
app = GoogleSearchGenerator(root)
|
||
|
root.mainloop()
|