curl 远程登录 以及远程发贴问题 本帖最后由 life169 于 2010-12-06 14:29:33 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 cookie得获取(http 返回头中的set-Cookie项)并反馈过去(http请求头中的cookie项)。$login_url = "http://www.czhi-fi.com/bbsxp/login.asp";//登录页地址$source_url = "http://www.czhi-fi.com/bbsxp/default.asp";//源页地址$post_fields = array();//以下两项固定值/*$post_fields['menu'] = 'add';$post_fields['url'] = 'http://www.czhi-fi.com/bbsxp/Default.asp';//用户名和密码,必须填写$post_fields['username'] = "mytest";$post_fields['userpass'] = "111111";*/$cookie="cookie.txt";$ch = curl_init($login_url);curl_setopt($ch, CURLOPT_REFERER, $source_url);curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_POST, 1);curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);curl_setopt($ch, CURLOPT_POSTFIELDS, 'username=mytest&userpass=111111&menu=add&url=http://www.czhi-fi.com/bbsxp/Default.asp');curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // 允许自动跳转$contents = curl_exec($ch);curl_close($ch);echo $contents; 高手就是高手感谢 “foolbirdflyfirst”作答。Thank you! php文件下载 正则替换掉js、html、空白、html实体、img标记及其路径(问题:我不想替换img标记,怎么改?) 如何实现select全选 in查询的问题 请教snnopy的一个方法! 数组初学者问题 关于php header()的使用问题 好奇怪的图片上传问题????? Ltsky.com ,谢谢帮忙。进来领分。 谁有treeview的例子 json取值问题 如何保留CDATA编辑XML节点中的值???
$source_url = "http://www.czhi-fi.com/bbsxp/default.asp";//源页地址
$post_fields = array();
//以下两项固定值
/*$post_fields['menu'] = 'add';
$post_fields['url'] = 'http://www.czhi-fi.com/bbsxp/Default.asp';//用户名和密码,必须填写
$post_fields['username'] = "mytest";
$post_fields['userpass'] = "111111";*/
$cookie="cookie.txt";
$ch = curl_init($login_url);
curl_setopt($ch, CURLOPT_REFERER, $source_url);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'username=mytest&userpass=111111&menu=add&url=http://www.czhi-fi.com/bbsxp/Default.asp');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // 允许自动跳转
$contents = curl_exec($ch);
curl_close($ch);
echo $contents;