python 使用COM执行JS

import win32com.client, pythoncom
from time import sleep
   
ie=win32com.client.Dispatch('internetexplorer.application')
ie.Visible=1
ie.Navigate('http://www.cpplab.com/Articles/JSCalls/TestPage/JSCallTestPage.htm')
sleep(5)  # Give it time to get there.
   
id=ie.Document.Script._oleobj_.GetIDsOfNames('Multiply') # 'Multiply' is the function name.
#5 and 2 below are the parameters passed to the function 'Multiply'.
res=ie.Document.Script._oleobj_.Invoke(id, 0, pythoncom.DISPATCH_METHOD, True, 5, 2)

你可能感兴趣的:(python 使用COM执行JS)