When I suddenly encountered a problem at work today, I tried to think about things as the leaders said.CodeI forgot about it. I thought of using thunder to download some things. Thunder didn't know what happened, but I knew that he was monitoring the Computer Browser. So when I wanted to download something, you can get an address that complies with the thunder protocol. You can use the webbrowser module to open this address and call thunder to do my own thing.
Import webbrowser
Webbrowser. Open ('Http://www.google.com.hk/')
I am using a Windows operating system. This module is actually simpler and more primitive for us to use:
If sys. platform [: 3] = "win": Class windowsdefault (basebrowser): def open (self, URL, new = 0, autoraise = 1): Try: OS. startfile (URL) failed t windowserror: # [error 22] No application is associated with the specified # file for this operation: '
'Return false else: return true _ tryorder = [] _ browsers ={}# first try to use the default Windows browser register ("Windows-Default", windowsdefault) # detect some common Windows browsers, fallback to IE iexplore = OS. path. join (OS. environ. get ("ProgramFiles", "C: \ Program Files"), "Internet Explorer \ iw.e. EXE ") for browser in (" Firefox "," Firebird "," SeaMonkey "," Mozilla "," Netscape "," Opera ", istme): If _ iscommand (browser): Register (browser, none, backgroundbroister (browser)
The operating system is different. There will be differences here. In fact, the most useful one is the OS. startfile (URL) can also obtain the effect of webbrower module open, but we recommend webbrower because it is more compatible.
Think of it here, with the keyboard operation module, sendkeys, and mouse simulation operations, you can certainly make quite good things.