curl-如何进入下一页? [英] curl - how to go to the next page?

查看:56
本文介绍了curl-如何进入下一页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我成功使用curl登录了.

I successfully logged in using curl.

$ch = curl_init('http://site.com/login');
// setting posts, cookies file, headers 
curl_exec($ch);

然后,在登录后,我需要转到其他页面,说 http://site.com/profit 做一些事情.

Then, while logged in, I need to go to other page, lets say http://site.com/profit to do some stuff.

但是如何?
我应该使用 $ ch = curl_init('http://site.com/profit')运行其他php脚本,还是可以在一个文件中执行?应该怎么做?

But how?
Should I run other php's script with $ch = curl_init('http://site.com/profit'), or is it possible to do in one file? How it should be done?

推荐答案

在同一PHP脚本中,可以根据需要多次使用curl.请确保在两次请求之间调用 curl_close($ ch).确保您的cookie jar文件(使用CURLOPT_COOKIEJAR指定)正在写入....

You can use curl as many times as you want in the same PHP script. Be sure to call curl_close($ch) between requests. Make sure that your cookie jar file (specified using CURLOPT_COOKIEJAR) is getting written to....

这篇关于curl-如何进入下一页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆