Python可以与 Chrome 等应用程序配合使用吗?
类似的东西:
from Tkinter import *
from (straightAccesToApps) import (straightAccesToApps)
main = Tk()
def runChrome():
straightAccesToApps('C:\\Desktop\Chrome').run()
main.quit()
Button(main, text="Chrome", command=runChrome).pack()
main.mainloop()
答案 0 :(得分:3)
是的,python可以通过多种方式实现:
1.Via模块,如webbrowser:
url = 'http://www.python.org/'
# Open URL in a new tab, if a browser window is already open.
webbrowser.open_new_tab(url + 'doc/')
# Open URL in new window, raising the window if possible.
webbrowser.open_new(url)
2.Via os.system
或subprocess.call
:
import os
os.system("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe -ArgumentList @( '-incognito', 'www.site.com'" )
3.Via powershell但这有点过分
import subprocess
subprocess.call(["C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe", ". \"./SamplePowershell\";", 'Start-Process "chrome.exe" "www.google.com"'])
答案 1 :(得分:0)
通过selenium webdriver,事实上的行业标准:http://www.seleniumhq.org