IE をスレッド内で終了させようとしています。google.com または facebook.com に移動しても問題はなく、問題なくie.Quit()
動作します。ただし、会社の共有サイトに移動すると、次のようになります。
Error in IEThread: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147467259), None
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\python27\lib\threading.py", line 808, in __bootstrap_inner
self.run()
File "PepTalk.pyw", line 404, in run
ie.Quit()
File "C:\python27\lib\site-packages\win32com\client\dynamic.py", line 522, in __getattr__
raise AttributeError("%s.%s" % (self._username_, attr))
AttributeError: InternetExplorer.Application.Quit
AttributeError は、同じスクリプトを別のアドレスで実行できるようにするためのものであるため、意味がありません。私は独自のスレッドで IE を実行しています。これが私のコードです。
class IEThread(Thread):
def __init__(self):
Thread.__init__(self)
self.queue = Queue()
def run(self):
ie = None
pythoncom.CoInitialize()
try:
ie = Dispatch('InternetExplorer.Application')
ie.Visible = 1
url = self.queue.get()
print 'Visiting...', url
ie.Navigate(url)
while ie.Busy:
time.sleep(0.1)
except Exception, e:
print "Error in IEThread: ", e
if ie is not None:
ie.Quit()
ieThread = IEThread()
ieThread.start()
url = 'https://company.sharepoint.com/company/Shared Documents/Weekly Pep Talk/2013/'
ieThread.queue.put(url)
なぜこれが起こるのでしょうか?