我编写了一个小 Python 脚本,每六秒以编程方式在 chrome 中打开 url。
#!/usr/bin/env python
import webbrowser
import time
f = open("data.txt", "r")
urls = f.readlines()
safari = webbrowser.get('open -a /Applications/Google\ Chrome.app %s')
for url in urls:
safari.open(url.replace("\n", ""))
print url
time.sleep(6)
我想知道是否有一种方法可以将 HTTP 错误(即 404)从 Chrome 捕获回 python。