BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / www-technology / #5518同步于 2008/12/21
WWWTechnology机器人发帖

[合集] 呼唤使用过libcurl的达人

tntzwz
2008/12/21镜像同步0 回复
☆─────────────────────────────────────☆ ccliu (过客匆匆) 于 (Wed Dec 3 10:26:36 2008) 提到: 想借助于libcurl这个库来模拟浏览器提交表单的操作,具体的来说就是想在linux下写一个程序来自动登录邮箱。我的代码如下: include <stdio.h> #include <curl/curl.h> int postUrl(char *filename) { CURL *curl; CURLcode res; FILE *fp; if ((fp = fopen(filename, "w")) == NULL) return 0; curl = curl_easy_init(); if (curl) { curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); // Allow redirection curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "/tmp/cookie.txt"); curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "/tmp/cookie.txt"); // 指定cookie文件 curl_easy_setopt(curl, CURLOPT_PROXY, "proxy.bupt.edu.cn:8080"); curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD,"xxx:xxx"); curl_easy_setopt(curl, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)"); curl_easy_setopt(curl, CURLOPT_URL, "http://mail.163.com/"); // 指定url curl_easy_setopt(curl, CURLOPT_POST, 1); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "username=xxx&password=xxx"); // 指定post内容 curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } fclose(fp); return 0; } int main(void) { postUrl("/home/tmp/tomdisk"); } gcc post.c -o post -lcurl ./post 运行结果只能得到163邮箱的登录页面,根本没进到邮箱去!请问我的问题出在哪啊?请达人们多多指教! ☆─────────────────────────────────────☆ yegle (一阁@SL小分队@lp是大牛) 于 (Wed Dec 3 10:33:25 2008) 提到: 把所需的数据都post过去了么? 【 在 ccliu (过客匆匆) 的大作中提到: 】 : 想借助于libcurl这个库来模拟浏览器提交表单的操作,具体的来说就是想在linux下写一个程序来自动登录邮箱。我的代码如下: : include <stdio.h> : #include <curl/curl.h> : ................... ☆─────────────────────────────────────☆ ccliu (过客匆匆) 于 (Wed Dec 3 10:43:57 2008) 提到: 除了用户名和口令,还需要其它数据吗? ☆─────────────────────────────────────☆ coolfantasy (Cool) 于 (Wed Dec 3 10:45:38 2008) 提到: form 里估计不止这两个字段 ☆─────────────────────────────────────☆ yegle (一阁@SL小分队@lp是大牛) 于 (Wed Dec 3 10:47:31 2008) 提到: POST /logins.jsp type=1&product=urs&username=yegle%40163.com&password=XXXXXX&Submit=%E7%99%BB%E3%80%80%E5%BD%95 现在系统繁忙,登录不上=。= 【 在 ccliu (过客匆匆) 的大作中提到: 】 : 除了用户名和口令,还需要其它数据吗? ☆─────────────────────────────────────☆ ccliu (过客匆匆) 于 (Wed Dec 3 10:48:04 2008) 提到: <input name="verifycookie" type="hidden" value="1" /> <input type="hidden" name="style" id="txtStyle" value="34" /> <input class="login_table_text1_input" type="password" name="password" onMouseOver="fEvent('mouseover',this)" onFocus="fEvent('focus',this)" onBlur="fEvent('blur',this)" onMouseOut="fEvent('mouseout',this)" 是指类似于这种吗? ☆─────────────────────────────────────☆ ccliu (过客匆匆) 于 (Wed Dec 3 10:49:47 2008) 提到: 不太明白你的意思,是说服务器的问题,程序没错吗? 【 在 yegle 的大作中提到: 】 : POST /logins.jsp type=1&product=urs&username=yegle%40163.com&password=XXXXXX&Submit=%E7%99%BB%E3%80%80%E5%BD%95 : 现在系统繁忙,登录不上=。= ☆─────────────────────────────────────☆ benxiaohai (笨小孩) 于 (Wed Dec 3 11:10:29 2008) 提到: 126(163)邮箱使用的是https登录,所以你模拟登录的时候要加上这个参数 CURLOPT_SSL_VERIFYPEER
订阅后,新回复会通过你的通知中心匿名送达。
0 条回复
暂无回复 · 你可以订阅本帖等待新回复。