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 ...
随机推荐
- sqlserver数据库的启动
sqlserver实例几种启动的方法: (1)在WINDOWS服务控制台里手动启动,或者自动启动(默认) 第二种方式是SQLSERVER本身自已提供的启动方式,可以手动启动 (3)在SQLSERVER ...
- 码云和Git使用说明
Git下载网站: https://git-scm.com/download/win 码云网站 :https://gitee.com 下载Git,并一路下一步安装. 鼠标空白处右键点击,出现两个 ...
- (Linux基础学习)第三章:terminal与shell的简介和修改命令提示符颜色
第1节:terminal终端设备终端:键盘.鼠标.显示器物理终端(/dev/console):控制台console虚拟终端(tty:teletypewriters,/dev/tty# #为[1-6]) ...
- GCC使用总结
概念 GCC一开始是linux系统集成的用来编译C程序的编译器(GNU C Compiler),目前GCC已经不仅仅支持C语言了,因而其缩写名单意义也变成(GNU Compiler Collectio ...
- redis都有哪些数据类型?分别在哪些场景下使用比较合适?
(1)string 这是最基本的类型了,没啥可说的,就是普通的set和get,做简单的kv缓存 (2)hash 这个是类似map的一种结构,这个一般就是可以将结构化的数据,比如一个对象(前提是这个对象 ...
- python_并发编程——多进程的第二种启动方式
1.多进程的第二种启动方式 import os from multiprocessing import Process # 创建一个自定义类,继承Process类 class MyProcess(Pr ...
- .net框架-链表(LinkedList<T>)
链表LinkedList 优点:插入元素快 缺点:查找元素慢 .net framework只提供了泛型版本 继承接口:ICollection<T>, IEnumerable<T> ...
- 【Python学习】Python3 基本数据类型
参考学习地址:https://www.runoob.com/python3/python3-data-type.html Python3 基本数据类型 Python 中的变量不需要声明.每个变量在使用 ...
- logstash-output-jdbc使用
项目需要,使用logstash定时读取log文件,并插入mysql数据库中,output使用logstash-output-jdbc插件.该插件不是默认安装的,需要使用命令:bin/logstash- ...
- Longest Continuous Increasing Subsequence II
Description Given an integer matrix. Find the longest increasing continuous subsequence in this matr ...