以编程方式从 python 中清除 IE 缓存
Programmatically clear IE cache from python
我看到 'command line' 从命令行清除 IE 缓存的选项,但无法弄清楚如何从 python 或什至从 MS Dos 提示中以编程方式执行此操作.这是我从 Whosebug: clear cache of browser by command line:
中找到的
删除所有历史记录 - RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
仅删除历史记录 - RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1
仅删除 Cookie - RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2
仅删除临时 Internet 文件 - RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
仅删除表单数据 - RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16
仅删除密码历史记录 - RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32
所以我的问题是,如何使用子进程将上面的 'commands' 直接从 python 转换成我可以 运行 的东西,例如,这将清除 IE 缓存。
这对我有用。只需注释掉您不使用的任何命令即可 want/need.
import subprocess
commands = (
"RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255", # Deletes ALL History
"RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1", # Deletes History Only
"RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2", # Deletes Cookies Only
"RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8", # Deletes Temporary Internet Files Only
"RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16", # Deletes Form Data Only
"RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32", # Deletes Password History Only
)
for command in commands:
with subprocess.Popen(command) as p:
p.wait()
print(f"{p.returncode} - {command}")
我看到 'command line' 从命令行清除 IE 缓存的选项,但无法弄清楚如何从 python 或什至从 MS Dos 提示中以编程方式执行此操作.这是我从 Whosebug: clear cache of browser by command line:
中找到的删除所有历史记录 - RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
仅删除历史记录 - RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1
仅删除 Cookie - RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2
仅删除临时 Internet 文件 - RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
仅删除表单数据 - RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16
仅删除密码历史记录 - RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32
所以我的问题是,如何使用子进程将上面的 'commands' 直接从 python 转换成我可以 运行 的东西,例如,这将清除 IE 缓存。
这对我有用。只需注释掉您不使用的任何命令即可 want/need.
import subprocess
commands = (
"RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255", # Deletes ALL History
"RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1", # Deletes History Only
"RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2", # Deletes Cookies Only
"RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8", # Deletes Temporary Internet Files Only
"RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16", # Deletes Form Data Only
"RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32", # Deletes Password History Only
)
for command in commands:
with subprocess.Popen(command) as p:
p.wait()
print(f"{p.returncode} - {command}")