浏览代码

完成了页面分析器的:基本动作链(元素查找、元素动作、等待执行和执行JS)

Huan 5 年之前
父节点
当前提交
1cebc9c086
共有 2 个文件被更改,包括 314 次插入43 次删除
  1. 117 36
      Crawler_controller.py
  2. 197 7
      Web_Crawler.py

+ 117 - 36
Crawler_controller.py

@@ -4,7 +4,7 @@ import time
 from os.path import exists
 from os import mkdir
 import hashlib
-
+from time import sleep
 
 class URL_PAGE():
     def __init__(self,url,func='get'):
@@ -155,10 +155,10 @@ class Page_Parser:
     def add_base(self,func):  # 装饰器
         def wrap(browser=None,num=None,name=None, *args, **kwargs):
             try:
-                func(browser,num, name, *args, **kwargs)
-                return False
-            except:
+                func(browser=browser,num=num, name=name, *args, **kwargs)
                 return True
+            except:
+                return False
         return wrap
 
     def add_func(self,name,func):
@@ -169,7 +169,7 @@ class Page_Parser:
     def return_func(self):
         return self.func_list.copy()
 
-    def find_ID(self,id,not_all=False):
+    def find_ID(self,id,not_all=False,**kwargs):
         @self.add_base
         def find(browser, num, name, *args, **kwargs):
             nonlocal self,id
@@ -178,7 +178,7 @@ class Page_Parser:
             else:self.element_dict[f'{name}[{num}]'] = browser.find_elements_by_id(id)
         self.add_func(f'find_ID:{id}',find)#添加func
 
-    def find_class(self,class_name,not_all=False):
+    def find_class(self,class_name,not_all=False,**kwargs):
         @self.add_base
         def find(browser, num, name, *args, **kwargs):
             nonlocal self,class_name
@@ -187,7 +187,7 @@ class Page_Parser:
             else:self.element_dict[f'{name}[{num}]'] = browser.find_elements_by_class_name(class_name)#返回必须是list
         self.add_func(f'find_class:{class_name}',find)#添加func
 
-    def find_name(self,name_,not_all=False):
+    def find_name(self,name_,not_all=False,**kwargs):
         @self.add_base
         def find(browser, num, name, *args, **kwargs):
             nonlocal self,name_
@@ -196,7 +196,7 @@ class Page_Parser:
             else:self.element_dict[f'{name}[{num}]'] = browser.find_elements_by_name(name_)#返回必须是list
         self.add_func(f'find_name:{name_}',find)#添加func
 
-    def find_xpath(self,xpath,not_all=False):
+    def find_xpath(self,xpath,not_all=False,**kwargs):
         @self.add_base
         def find(browser, num, name, *args, **kwargs):
             nonlocal self,xpath
@@ -205,7 +205,7 @@ class Page_Parser:
             else:self.element_dict[f'{name}[{num}]'] = browser.find_elements_by_xpath(xpath)#返回必须是list
         self.add_func(f'find_xpath:{xpath}',find)#添加func
 
-    def find_css(self,css_selector,not_all=False):
+    def find_css(self,css_selector,not_all=False,**kwargs):
         @self.add_base
         def find(browser, num, name, *args, **kwargs):
             nonlocal self,css_selector
@@ -214,7 +214,7 @@ class Page_Parser:
             else:self.element_dict[f'{name}[{num}]'] = browser.find_elements_by_css_selector(css_selector)#返回必须是list
         self.add_func(f'find_css:{css_selector}',find)#添加func
 
-    def find_tag_name(self,tag_name,not_all=False):
+    def find_tag_name(self,tag_name,not_all=False,**kwargs):
         @self.add_base
         def find(browser, num, name, *args, **kwargs):
             nonlocal self,tag_name
@@ -223,7 +223,7 @@ class Page_Parser:
             else:self.element_dict[f'{name}[{num}]'] = browser.find_elements_by_tag_name(tag_name)#返回必须是list
         self.add_func(f'find_tagName:{tag_name}',find)#添加func\
 
-    def find_link_text(self,link_text,not_all=False):#匹配link
+    def find_link_text(self,link_text,not_all=False,**kwargs):#匹配link
         @self.add_base
         def find(browser, num, name, *args, **kwargs):
             nonlocal self,link_text
@@ -232,7 +232,7 @@ class Page_Parser:
             else:self.element_dict[f'{name}[{num}]'] = browser.find_elements_by_link_text(link_text)#返回必须是list
         self.add_func(f'find_link_text:{link_text}',find)#添加func
 
-    def find_partial_link_text(self,partial_link_text,not_all=False):#模糊匹配
+    def find_partial_link_text(self,partial_link_text,not_all=False,**kwargs):#模糊匹配
         @self.add_base
         def find(browser, num, name, *args, **kwargs):
             nonlocal self,partial_link_text
@@ -257,7 +257,7 @@ class Page_Parser:
             self.element_dict[f'{name}[{num}]'] = [browser.switch_to.active_element()]
         self.add_func(f'active_element',find)#添加func
 
-    def find_switch_to_frame(self,reference,is_id=False,*args,**kwargs):#定位弹出框
+    def find_switch_to_frame(self,reference,is_id=False,*args,**kwargs):#定位Frame
         @self.add_base
         def find(browser, num, name, *args, **kwargs):
             nonlocal self,reference,is_id
@@ -269,86 +269,167 @@ class Page_Parser:
             else:
                 if is_id:reference = int(reference)
                 self.element_dict[f'{name}[{num}]'] = [browser.switch_to.frame(str(reference))]# 定位进入文档
-        self.add_func(f'find_frame:{reference}',find)#添加func
+        func_name = {None:'主文档','':'父文档'}.get(reference,reference)
+        self.add_func(f'find_frame:{func_name}',find)#添加func
 
-    def send_keys(self,text,element_value,index=0):#输入文字
+    def send_keys(self,text,element_value,index=0,**kwargs):#输入文字
         @self.add_base
         def action(*args, **kwargs):
             nonlocal self
             self.element_dict[element_value][index].send_keys(text)
         self.add_func(f'sent_text:{text}>{element_value}[{index}]', action)  # 添加func
 
-    def User_Passwd(self,User,Passwd,element_value,index=0):#输入验证(User&Password)
+    def User_Passwd(self,User,Passwd,element_value,index=0,**kwargs):#输入验证(User&Password)
         @self.add_base
         def action(*args, **kwargs):
             nonlocal self
             self.element_dict[element_value][index].authenticate(User,Passwd)
-        self.add_func(f'sent_text:{User};{Passwd}>{element_value}[{index}]', action)  # 添加func
+        self.add_func(f'User:Passwd:{User};{Passwd}>{element_value}[{index}]', action)  # 添加func
 
-    def clear(self,element_value,index=0):#清空文本
+    def clear(self,element_value,index=0,**kwargs):#清空文本
         @self.add_base
         def action(*args, **kwargs):
             nonlocal self
             self.element_dict[element_value][index].clear()
         self.add_func(f'clear_text>{element_value}[{index}]', action)  # 添加func
 
-    def click(self,element_value,index=0):#点击按钮
+    def click(self,element_value,index=0,**kwargs):#点击按钮
         @self.add_base
         def action(*args, **kwargs):
             nonlocal self
             self.element_dict[element_value][index].click()
         self.add_func(f'click>{element_value}[{index}]', action)  # 添加func
 
-    def accept(self,element_value,index=0):#点击确定(弹出框)
+    def accept(self,element_value,index=0,**kwargs):#点击确定(弹出框)
         @self.add_base
         def action(*args, **kwargs):
             nonlocal self
             self.element_dict[element_value][index].accept()
         self.add_func(f'accept>{element_value}[{index}]', action)  # 添加func
 
-    def dismiss(self,element_value,index=0):#点击取消(弹出框)
+    def dismiss(self,element_value,index=0,**kwargs):#点击取消(弹出框)
         @self.add_base
         def action(*args, **kwargs):
             nonlocal self
             self.element_dict[element_value][index].dismiss()
         self.add_func(f'dismiss>{element_value}[{index}]', action)  # 添加func
 
-    def submit(self,element_value,index=0):#点击按钮
+    def submit(self,element_value,index=0,**kwargs):#提交表单
         @self.add_base
         def action(*args, **kwargs):
             nonlocal self
             self.element_dict[element_value][index].submit()
         self.add_func(f'submit>{element_value}[{index}]', action)  # 添加func
 
-    def deselect_by_index(self,element_value,deselect_index,index=0):#根据index取消选择
+    def deselect_by_index(self,element_value,deselect,index=0,**kwargs):#根据index取消选择
+        @self.add_base
+        def action(*args, **kwargs):
+            nonlocal self
+            self.element_dict[element_value][index].deselect_by_index(int(deselect))
+        self.add_func(f'deselect_by_index:{deselect}>{element_value}[{index}]', action)  # 添加func
+
+    def deselect_by_text(self,element_value,deselect,index=0,**kwargs):#根据text取消选择
+        @self.add_base
+        def action(*args, **kwargs):
+            nonlocal self
+            self.element_dict[element_value][index].deselect_by_visible_text(deselect)
+        self.add_func(f'deselect_by_text:{deselect}>{element_value}[{index}]', action)  # 添加func
+
+    def deselect_by_value(self,element_value,deselect,index=0,**kwargs):#根据value取消选择
+        @self.add_base
+        def action(*args, **kwargs):
+            nonlocal self
+            self.element_dict[element_value][index].deselect_by_value(deselect)
+        self.add_func(f'deselect_by_value:{deselect}>{element_value}[{index}]', action)  # 添加func
+
+    def select_by_index(self,element_value,deselect,index=0,**kwargs):#根据index选择
+        @self.add_base
+        def action(*args, **kwargs):
+            nonlocal self
+            self.element_dict[element_value][index].select_by_index(int(deselect))
+        self.add_func(f'select_by_index:{deselect}>{element_value}[{index}]', action)  # 添加func
+
+    def select_by_text(self,element_value,deselect,index=0,**kwargs):#根据text选择
+        @self.add_base
+        def action(*args, **kwargs):
+            nonlocal self
+            self.element_dict[element_value][index].select_by_visible_text(deselect)
+        self.add_func(f'select_by_text:{deselect}>{element_value}[{index}]', action)  # 添加func
+
+    def select_by_value(self,element_value,deselect,index=0,**kwargs):#根据value选择
+        @self.add_base
+        def action(*args, **kwargs):
+            nonlocal self
+            self.element_dict[element_value][index].select_by_value(deselect)
+        self.add_func(f'select_by_value:{deselect}>{element_value}[{index}]', action)  # 添加func
+
+    def back(self,**kwargs):# 返回
+        @self.add_base
+        def action(*args, **kwargs):
+            nonlocal self
+            self.browser.back()
+        self.add_func(f'BACK', action)
+
+    def forward(self,**kwargs):# 前进
         @self.add_base
         def action(*args, **kwargs):
             nonlocal self
-            self.element_dict[element_value][index].deselect_by_index(int(deselect_index))
-        self.add_func(f'deselect_by_index:{deselect_index}>{element_value}[{index}]', action)  # 添加func
+            self.browser.forward()
+        self.add_func(f'FORWARD', action)
 
-    def deselect_by_text(self,element_value,deselect_text,index=0):#根据text取消选择
+    def refresh(self,**kwargs):# 刷新
         @self.add_base
         def action(*args, **kwargs):
             nonlocal self
-            self.element_dict[element_value][index].deselect_by_visible_text(deselect_text)
-        self.add_func(f'deselect_by_text:{deselect_text}>{element_value}[{index}]', action)  # 添加func
+            self.browser.refresh()
+        self.add_func(f'REFRESH', action)
 
-    def select_by_index(self,element_value,deselect_index,index=0):#根据index选择
+    def wait_sleep(self,time:int=2,**kwargs):#暴力等待
         @self.add_base
         def action(*args, **kwargs):
             nonlocal self
-            self.element_dict[element_value][index].select_by_index(int(deselect_index))
-        self.add_func(f'select_by_index:{deselect_index}>{element_value}[{index}]', action)  # 添加func
+            sleep(time)
+        self.add_func(f'WAIT:{time}s', action)
 
-    def select_by_text(self,element_value,deselect_text,index=0):#根据text选择
+    def set_wait(self,time:int=2,**kwargs):#隐式等待
         @self.add_base
         def action(*args, **kwargs):
             nonlocal self
-            self.element_dict[element_value][index].select_by_visible_text(deselect_text)
-        self.add_func(f'select_by_text:{deselect_text}>{element_value}[{index}]', action)  # 添加func
+            sleep(time)
+        self.add_func(f'Loading_wait:{time}s', action)
+
+    def run_JS(self,JS,**kwargs):
+        @self.add_base
+        def action(num,name,*args, **kwargs):
+            nonlocal self
+            get = self.browser.execute_script(JS)
+            if hasattr(get,'__getitem__'):#可切片
+                self.element_dict[f'{name}[{num}]'] = get  # 返回必须是list
+            else:
+                self.element_dict[f'{name}[{num}]'] = [get]
+        self.add_func(f'run_js:{JS}', action)
 
-    def Element_interaction(self):#元素交互
+    def Element_interaction(self,update_func=lambda *args:None):#元素交互
         func_list = self.func_list
+        status = None
+        def update(func_name):
+            nonlocal status,self
+            if status:
+                success_code = 'Success to run'
+            elif status is None:
+                success_code = 'No status'
+            else:
+                success_code = 'Wrong to run'
+            value_box = []
+            for i in self.element_dict:
+                try:
+                    value_box.append(f'{i}[{len(i)}] = {self.element_dict[i]}')
+                except:
+                    value_box.append(f'{i} = {self.element_dict[i]}')
+            update_func(func_name, success_code, value_box)  # 信息更新系统
+
         for func_num in range(len(func_list)):
-            self.func_dict[func_list[func_num]](num=f'{func_num}',name='var')
+            func_name = func_list[func_num]
+            update(func_name)
+            status = self.func_dict[func_name](num=f'{func_num}',name='var')
+        update('Finish')

+ 197 - 7
Web_Crawler.py

@@ -79,10 +79,10 @@ def Main():
     cookies_fixed.set('0')
 
     a_y += 1
-    cookies_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B * 7)
-    cookies_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=7, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
+    cookies_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B * 8)
+    cookies_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=8, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
 
-    a_y += 7
+    a_y += 8
     tkinter.Button(top, bg=bbg, fg=fg, text='清空曲奇',command=Tra_cookies, font=FONT, width=width_B,height=height_B).grid(
         column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
     tkinter.Button(top, bg=bbg, fg=fg, text='更新曲奇',command=Update_cookies, font=FONT, width=width_B,height=height_B).grid(
@@ -137,6 +137,142 @@ def Main():
     Parser_Func_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B * 4)
     Parser_Func_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=4, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
 
+    global Var_Input,VarIndex_Input,Send_Input,UserPW_Input,SELE_Input,JS_Input,Time_Input
+    a_y += 4
+    tkinter.Label(top, text='操作元素:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y)
+    Var_Input = tkinter.Entry(top, width=width_B * 2)
+    Var_Input.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Label(top, text='操作索引:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y)
+    VarIndex_Input = tkinter.Entry(top, width=width_B * 2)
+    VarIndex_Input.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Label(top, text='发送信息:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y)
+    Send_Input = tkinter.Entry(top, width=width_B * 2)
+    Send_Input.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Label(top, text='认证用户名:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y)
+    UserName_Input = tkinter.Entry(top, width=width_B * 2)
+    UserName_Input.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Label(top, text='认证密码:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y)
+    UserPW_Input = tkinter.Entry(top, width=width_B * 2)
+    UserPW_Input.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Label(top, text='选择参数:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y)
+    SELE_Input = tkinter.Entry(top, width=width_B * 2)
+    SELE_Input.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Label(top, text='等待时间:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y)
+    Time_Input = tkinter.Entry(top, width=width_B * 2)
+    Time_Input.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Label(top, text='JavaScript:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y)
+    JS_Input = tkinter.Entry(top, width=width_B * 2)
+    JS_Input.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Button(top, bg=bbg, fg=fg, text='发送字符',command=lambda :Page_Parser_addActionFunc('send_keys'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='清空字符',command=lambda :Page_Parser_addActionFunc('clear'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='提交表单',command=lambda :Page_Parser_addActionFunc('submit'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Button(top, bg=bbg, fg=fg, text='点击按钮',command=lambda :Page_Parser_addActionFunc('click'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x,columnspan=3, row=a_y, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Button(top, bg=bbg, fg=fg, text='切换Frame(id)',command=Page_Parser_addFrameFunc_id, font=FONT, width=width_B,height=height_B).grid(
+        column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='切换Frame',command=lambda :Page_Parser_addFindFunc('frame'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='定位焦点元素',command=lambda :Page_Parser_addFindFunc('active_element'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Button(top, bg=bbg, fg=fg, text='捕获弹窗',command=lambda :Page_Parser_addFindFunc('alert'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='回到主Frame',command=lambda :Page_Parser_addFrameFunc_FP(False), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='回到父Frame',command=lambda :Page_Parser_addFrameFunc_FP(True), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Button(top, bg=bbg, fg=fg, text='弹出框认证',command=lambda :Page_Parser_addActionFunc('User_Passwd'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='弹出框确定',command=lambda :Page_Parser_addActionFunc('accept'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='弹出框取消',command=lambda :Page_Parser_addActionFunc('dismiss'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Button(top, bg=bbg, fg=fg, text='取消选择index',command=lambda :Page_Parser_addActionFunc('deselect_by_index'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='取消选择text',command=lambda :Page_Parser_addActionFunc('deselect_by_text'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='取消选择value',command=lambda :Page_Parser_addActionFunc('deselect_by_value'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Button(top, bg=bbg, fg=fg, text='选择index',command=lambda :Page_Parser_addActionFunc('select_by_index'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='选择text',command=lambda :Page_Parser_addActionFunc('select_by_text'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='选择value',command=lambda :Page_Parser_addActionFunc('select_by_value'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Button(top, bg=bbg, fg=fg, text='页面后退',command=lambda :Page_Parser_addActionFunc('back'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='页面刷新',command=lambda :Page_Parser_addActionFunc('refresh'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='页面前进',command=lambda :Page_Parser_addActionFunc('forward'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Button(top, bg=bbg, fg=fg, text='暴力等待',command=lambda :Page_Parser_addActionFunc('wait_sleep'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='元素检查等待',command=lambda :Page_Parser_addActionFunc('set_wait'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='运行js',command=lambda :Page_Parser_addActionFunc('run_JS'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W)
+
+    a_x += 3
+    tkinter.Label(top, text='', bg=bg, fg=fg, font=FONT, width=1).grid(column=a_x, row=a_y)  # 设置说明
+    a_x += 1
+    a_y = 0
+
+    global Func_Output,Status_Output,FuncValue_BOX
+    tkinter.Label(top, text='正在执行:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y)
+    Func_Output = tkinter.Entry(top, width=width_B * 2, state=tkinter.DISABLED)
+    Func_Output.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Label(top, text='上一次状态:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y)
+    Status_Output = tkinter.Entry(top, width=width_B * 2, state=tkinter.DISABLED)
+    Status_Output.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    FuncValue_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B * 5)
+    FuncValue_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=5, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
+
+    a_y += 5
+    tkinter.Button(top, bg=bbg, fg=fg, text='NONE',command=lambda :Page_Parser_addActionFunc('wait_sleep'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='NONE',command=lambda :Page_Parser_addActionFunc('set_wait'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='NONE',command=lambda :Page_Parser_addActionFunc('run_JS'), font=FONT, width=width_B,height=height_B).grid(
+        column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W)
+
     top.update()#要预先update一下,否则会卡住
     global url,loader,Page_Parser
     save_dir = askdirectory(title='选择项目位置')#项目位置
@@ -145,15 +281,69 @@ def Main():
     Page_Parser = Crawler_controller.Page_Parser(loader)
     top.mainloop()
 
+def update_Status(now_func,status,Value_BOX):
+    global Func_Output,Status_Output,FuncValue_BOX
+    Func_Output.set(now_func)
+    Status_Output.set(status)
+    FuncValue_BOX.delete(0,tkinter.END)
+    FuncValue_BOX.insert(0,*Value_BOX)
+
+def Func_Args():#方法args统一转换(不支持Frame)
+    global Var_Input, VarIndex_Input, Send_Input, UserPW_Input, SELE_Input, JS_Input, Time_Input
+    try:
+        time = int(Time_Input.get())
+    except:
+        time = 2
+    try:
+        index = int(VarIndex_Input.get())
+    except:
+        index = 0
+    return dict(
+    element_value = Var_Input.get(),
+    index = index,
+    text = Send_Input.get(),
+    User = UserPW_Input.get(),
+    Passwd = UserPW_Input.get(),
+    deselect = SELE_Input.get(),
+    JS = JS_Input.get(),
+    time=time
+    )
+
+def Page_Parser_addActionFunc(func):
+    global Page_Parser
+    args = Func_Args()
+    FUNC = {'send_keys':Page_Parser.send_keys,'clear':Page_Parser.clear,'click':Page_Parser.click,'User_Passwd':Page_Parser.User_Passwd,
+            'accept':Page_Parser.accept,'dismiss':Page_Parser.dismiss,'submit':Page_Parser.submit,'deselect_by_index':Page_Parser.deselect_by_index,
+            'deselect_by_value':Page_Parser.deselect_by_value,'deselect_by_text':Page_Parser.deselect_by_text,'select_by_index':Page_Parser.select_by_index,
+            'select_by_value':Page_Parser.select_by_value,'select_by_text':Page_Parser.select_by_text,'back':Page_Parser.back,'forward':Page_Parser.forward,
+            'refresh':Page_Parser.refresh,'wait_sleep':Page_Parser.wait_sleep,'set_wait':Page_Parser.set_wait,'run_JS':Page_Parser.run_JS}.get(
+        func,Page_Parser.send_keys
+    )
+    FUNC(**args)
+    Update_Parser_Func_BOX()
+
+def Page_Parser_addFrameFunc_FP(F=True):
+    global Page_Parser, search_Input
+    search = None if F else ''
+    Page_Parser.find_switch_to_frame(search,True)
+    Update_Parser_Func_BOX()
+
+def Page_Parser_addFrameFunc_id():
+    global Page_Parser, search_Input
+    search = search_Input.get()
+    Page_Parser.find_switch_to_frame(search,True)
+    Update_Parser_Func_BOX()
+
 def Page_Parser_addFindFunc(func):
     global search_all, search_Input,Page_Parser
     not_all = not(bool(search_all.get()))
     search = search_Input.get()
     FUNC = {'id':Page_Parser.find_ID,'name':Page_Parser.find_name,'class':Page_Parser.find_class,
             'xpath':Page_Parser.find_xpath,'css':Page_Parser.find_css,'tag':Page_Parser.find_tag_name,
-            'link':Page_Parser.find_link_text,'partial_link':Page_Parser.find_partial_link_text}.get(
-        func,Page_Parser.find_ID)
-    FUNC(search,not_all)
+            'link':Page_Parser.find_link_text,'partial_link':Page_Parser.find_partial_link_text,
+            'alert':Page_Parser.find_switch_to_alert,'active_element':Page_Parser.find_switch_to_active_element,
+            'frame':Page_Parser.find_switch_to_frame}.get(func,Page_Parser.find_ID)
+    FUNC(search,not_all=not_all)
     Update_Parser_Func_BOX()
 
 def Update_Parser_Func_BOX():
@@ -213,7 +403,7 @@ def startDownloader():
     def startLoader():
         global loader,Page_Parser
         loader.strat_urlGet(func_cookie=cookies_BOX_Update)
-        Page_Parser = Crawler_controller.Page_Parser(loader)
+        Page_Parser.Element_interaction(update_Status)
 
     new = threading.Thread(target=startLoader)
     new.start()