<分区>
如何通过 linux shell 检查特定的 url 是否有效?我尝试通过 elinks,但它显示:
错误:此应用程序需要在浏览器中启用 javascript
<分区>
如何通过 linux shell 检查特定的 url 是否有效?我尝试通过 elinks,但它显示:
错误:此应用程序需要在浏览器中启用 javascript
最佳答案
您可以使用 curl 轻松地做到这一点(如果您的系统还没有安装 curl,您可能必须安装它)。
例如,表演
curl -Is [URL YOU WANT TO CHECK] | head -n 1
会给你一个http status code .然后,您可以根据此状态代码确定 url 是否存在。例如:
curl -Is http://stackoverflow.com/questions/21597851/how-to-check-whether-url-is-working-or-not-through-linux-shell | head -n 1
即您的问题将返回 200 状态代码。 HTTP/1.1 200 OK
但是另一个url比如
curl -Is http://stackoverflow.com/questions/madeupquestion/example | head -n 1
将返回 404,因为它不存在。 HTTP/1.1 404 未找到
关于linux - 如何通过 linux shell 检查 url 是否正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21597851/