php - 使用curl 进行多个请求(不是“多线程”)

发布于 2024-08-02 01:23:03 字数 220 浏览 3 评论 0原文

如果我想用curl做多项事情(需要cookie),例如:

  1. 登录到(我自己的)博客
  2. ,然后自动提交博客文章,

我是在curl关闭之前在一个curl实例中执行此操作还是关闭第一个会话,然后为第二个任务开始第二个? (很抱歉,如果这是一个愚蠢的问题,但我不太明白。通常,我在网上找到的有关curl的所有示例都只做了一件事......这无助于我理解它。)

If i want to do multiple things (that require cookies) with curl, for example:

  1. login to (my own) blog
  2. then automatically submit a blog post

do I do this in one curl instance before curl close or do i close first session and then start second one for second task? (Sorry if it's dumb question but i can't quite get it. Generally all examples on the net i find about curl are doing only one thing... this doesn't help me with understanding it.)

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

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

发布评论

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

评论(2

橘亓 2024-08-09 01:23:03

一般来说:

  1. 初始化curl。 (curl_init,或 < a href="http://www.php.net/manual/en/function.curl-multi-init.php" rel="nofollow noreferrer">curl_multi_init)
  2. 做事(s)。 (在多个 curl_exec 调用中如果需要,或 curl_multi_exec)
  3. 关闭卷曲。 (curl_closecurl_multi_close

所以是的,全部在一个会话中完成。

Generally speaking:

  1. Initialize curl. (curl_init, or curl_multi_init)
  2. Do thing(s). (in multiple curl_exec calls if needed, or curl_multi_exec)
  3. Close curl. (curl_close or curl_multi_close)

So yes, all in one session.

提笔书几行 2024-08-09 01:23:03

是,在移动到下一个之前打开并关闭每个卷曲对象。

Yes open and close each curl object before moving to the next.

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