phpcurl“无法连接到主机”的故障转移功能

发布于 2024-09-08 20:56:13 字数 165 浏览 2 评论 0原文

我有一个 php curl 脚本,可以抓取不同的网站。问题是,过了一段时间,我认为网站对我的 IP 施加了某种临时禁令,并且脚本无法再连接到主机(因为我收到“无法连接到主机”错误)。我想设置一个条件/函数来使脚本停止一段时间(例如 sleep(30)),但我不知道当 cURL 无法连接到主机时如何检测(处理错误)。

I have a php curl script which crawls different websites . The problem is that after a while I think the websites place a kind of temporary ban on my IP and the script is unable to connect to the host anymore(as I'm getting "couldn't connect to host" error) . I would like to set a condition/function to make the script stop for a while (e.g sleep(30)) but I don't know how to detect(handle the error) when cURL is unable to connect to the host.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我只土不豪 2024-09-15 20:56:13

php.net/curl_errno

php.net/curl_errno

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文