c++ curl 登陆renren.com (cookie的使用)<转>
size_t write_callback( void *ptr, size_t size, size_t nmemb, void *stream )
{
int len = size * nmemb;
int written = len; if ( access( (char*)stream, ) == - )
{
fp = fopen( (char*) stream, "wb" );
}
else
{
fp = fopen( (char*) stream, "ab" );
}
if (fp)
{
fwrite( ptr, size, nmemb, fp );
}
return written;
} int PostUrlchar* url, void *savepath)
{
// 初始化libcurl
CURLcode return_code;
return_code = curl_global_init(CURL_GLOBAL_WIN32);
if (CURLE_OK != return_code)
return ;
CURL *curl_handle;
CURLcode res;
curl_handle = curl_easy_init();
curl_easy_setopt(curl_handle, CURLOPT_URL, url);
curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, true);
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8");
curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR, "cookie.txt");
curl_easy_setopt(curl_handle, CURLOPT_COOKIEFILE, "cookie.txt");
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_callback);
curl_easy_setopt( curl_handle, CURLOPT_WRITEDATA, savepath );
curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS,postLoginData);
res = curl_easy_perform(curl_handle);
curl_easy_cleanup(curl_handle);
curl_global_cleanup();
if (res == CURLE_OK)
{
return ;
}
return ;
} int GetUrl(string url,void *buffer)
{
// 初始化libcurl
CURLcode return_code;
return_code = curl_global_init(CURL_GLOBAL_WIN32);
if (CURLE_OK != return_code)
return ;
CURL *easy_handle = curl_easy_init();
if (NULL == easy_handle)
{
curl_global_cleanup();
return ;
}
// 设置easy handle属性
curl_easy_setopt(easy_handle, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8");
curl_easy_setopt(easy_handle,CURLOPT_FOLLOWLOCATION,TRUE);
curl_easy_setopt(easy_handle, CURLOPT_URL, url.c_str());
curl_easy_setopt(easy_handle, CURLOPT_WRITEFUNCTION, write_callback);
curl_easy_setopt(easy_handle, CURLOPT_WRITEDATA, buffer);
curl_easy_setopt(easy_handle, CURLOPT_COOKIEFILE,"cookie.txt");
curl_easy_setopt(easy_handle, CURLOPT_COOKIEJAR, "cookie.txt");
curl_easy_perform(easy_handle);
curl_easy_cleanup(easy_handle);
curl_global_cleanup();
return ;
}
.先post登陆到url。 .再访问自己的主页。 可以使用Wireshark抓取各个web地址,及post具体格式的数据。
原帖地址:https://www.xuebuyuan.com/725671.html
c++ curl 登陆renren.com (cookie的使用)<转>的更多相关文章
- php curl 登陆百度贴吧(经历记录)
这两天,因为公司需要,所以研究了一下百度文库的登陆方案.因为账号是购买的,只有一部分cookie值,所以不能通过正常的渠道登陆,所以只有通过curl模拟直接进行后台登陆.那么,问题来了.按照人家说的, ...
- 登陆后设置cookie的方法
public void SetCookie(string userName, string role,string cookieValueName) {FormsAuthentication.Form ...
- php cUrl模拟登录,cookie保存到文件中
源码如下: <?php header("Content-Type:text/html;charset=utf-8"); //模拟群友通讯录手机号登录 $curl = curl ...
- PHP 通过curl POST传递 伪造cookie 传递信息
一些论坛网站需要每日签到太麻烦,于是写了一个Win 的定时任务,通过curl 去处理传递的伪造Cookie 和 header; 有不妥的地方,希望各位大佬们多多指正,谢谢各位大佬: $fp = @fo ...
- 如何实现免登陆功能(cookie session?)
Cookie的机制 Cookie是浏览器(User Agent)访问一些网站后,这些网站存放在客户端的一组数据,用于使网站等跟踪用户,实现用户自定义功能. Cookie的Domain和Path属性标识 ...
- HttpWebRequest模拟登陆,存储Cookie以便登录请求后使用
[一篮饭特稀原创,转载请注明出自http://www.cnblogs.com/wanghafan/p/3284481.html] PostLogin :登录,并保存Cookie 1 public st ...
- Fiddler如何查找登陆的可用cookie用于其他请求?方式一
测试过程中,如果你的请求权限是通过cookie响应而不是通过token获得,那么使用如下设置: 1.进入fiddler抓取: 2.jmeter中使用cookie 直接放进去就好了,一般浏览器cooki ...
- python requests使用登陆之后的cookie
def getcontent(self): cookie_text=r'ur=FTW; mid=WsrlLwAEAAEfpCstNyTJl-1oZa0w; ig_pr=1; ig_vh=949; cs ...
- PHP实现curl和snoopy类模拟登陆方法
Snoopy.class.php下载 方法/步骤 第一种:使用snoopy类实现模拟登陆 1.在网上下载一个Snoopy.class.php的文件 2.代码实现: <?php set_t ...
随机推荐
- org.apache.shiro.session.UnknownSessionException: There is no session with id [xxxx]的解决方案
org.apache.shiro.session.UnknownSessionException: There is no session with id [xxxx]的解决方案 背景描述 Sprin ...
- ORACLE 无法访问表空间
问题描述: Oracle安装后创建用户,建表等都正常,但在插入数据的时候出现无法访问表空间 解决办法: ORACLE12权限管理比较严格需设置分配以下权限 系统权限赋值:unlimited t ...
- Makefile学习二
今天继续对Makefile进行研究,话不多说,进入正题: make常用内嵌函数: 下面利用上面的知识点来实现一个多级目录的Makefile,如下: 多级目录Makefile: 这个例子的目录结构如下: ...
- Centos7安装nginx后提示“Welcome to nginx on Fedora!”,conf.d目录下无default.conf文件
问题描述 在腾讯云centos7上安装nginx sudo yum install nginx 打开默认网页显示 Welcome to nginx on Fedora! 且 /etc/nginx/co ...
- wordpress实现主动推送+熊掌号推送同步进行
今天给一个朋友http://www.myunigift.cn/ 这个站点是用wordpress,今天帮他改造熊掌号,于是做了数据同步推送. 只要把下面的代码写到funtions.php里面,发布文章的 ...
- 行为型模式(四) 观察者模式(Observer)
一.动机(Motivate) "观察者模式"在现实生活中,实例其实是很多的,比如:八九十年代我们订阅的报纸,我们会定期收到报纸,因为我们订阅了.银行可以给储户发手机短信,也是&qu ...
- Vue之@click、事件修饰符@click.stop与@click.prevent、按键修饰符@keyup.enter
1.绑定监听@click: (以监听click为例,其他如keyup,用法类似) v-on:click="fun" @click="fun" @click ...
- c语言实现整数转换为字符串——不考虑负数
#include <stdio.h> #include <string.h> #define MAX_LEN 16 #define ESP 1e-5 typedef int i ...
- 使用LoadRunner脚本并发下载文件,出现19890错误
需求:10个客户并发下载同一份zip文件.执行的时候,8个Fail了,只下载了两份zip,且无论执行多少遍,都是这样. 错误信息如下:message code:-19890C interpreter ...
- Canvas 总结,到第4章 canvas图形变换
canvas 必须认识到的大坑 <!-- 重点: 在js/canvas标签中定义的宽和高是画布实际的宽和高. 在样式表中定义的宽和高是画布缩放后的宽和高. 即:把js/canvas实际大小缩放到 ...