VC获取cookies的几种方法
方法一:
CInternetSession::GetCookie
This member function implements the behavior of the Win32 function InternetGetCookie, as
described in the Windows SDK.
static BOOL GetCookie(
LPCTSTR pstrUrl,
LPCTSTR pstrCookieName,
LPTSTR pstrCookieData,
DWORD dwBufLen
);
static BOOL GetCookie(
LPCTSTR pstrUrl,
LPCTSTR pstrCookieName,
CString& strCookieData
);
http://msdn.microsoft.com/en-us/library/vstudio/cff9kt47(v=vs.120).aspx
实现:
char * pszURL = "http://www.baidu.com/";
CInternetSession::GetCookie(pszURL, "", strCookie);
printf("%s\n", strCookie);
方法二:
InternetGetCookie
BOOL InternetGetCookie(
_In_ LPCTSTR lpszUrl,
_In_ LPCTSTR lpszCookieName,
_Out_ LPTSTR lpszCookieData,
_Inout_ LPDWORD lpdwSize
);
http://msdn.microsoft.com/en-us/library/ie/aa384710(v=vs.85).aspx
实现:
LPDWORD lpdwSize = new DWORD;
char strCookie_two[100] = {0};
InternetGetCookie(pszURL, NULL, strCookie_two, lpdwSize);
InternetGetCookie(pszURL, NULL, strCookie_two, lpdwSize);
printf("%s\n", strCookie_two);
方法三:
QueryInfo
CInternetSession session("HttpClient");
CHttpFile* pfile = (CHttpFile *)session.OpenURL(pszURL);
CString strCookie_three;
pfile->QueryInfo(HTTP_QUERY_SET_COOKIE, strCookie_three);
printf("%s\n", strCookie_three);
Managing Cookies
//获取cookies的几种方法
#include <afxinet.h>
#include <atlstr.h>
#include <cstdio> int main()
{
char * pszURL = "http://blog.csdn.net/x_iya"; //方法一
printf("方法一:\n");
CString strCookie_one;
CInternetSession::GetCookie(pszURL, "", strCookie_one);
printf("%s\n", strCookie_one); //方法二
printf("方法二:\n");
LPDWORD lpdwSize = new DWORD;
char strCookie_two[100] = {0};
InternetGetCookie(pszURL, NULL, strCookie_two, lpdwSize);
InternetGetCookie(pszURL, NULL, strCookie_two, lpdwSize);
printf("%s\n", strCookie_two); //方法三
printf("方法三:\n");
CInternetSession session("HttpClient");
CHttpFile* pfile = (CHttpFile *)session.OpenURL(pszURL);
CString strCookie_three;
pfile->QueryInfo(HTTP_QUERY_SET_COOKIE, strCookie_three);
printf("%s\n", strCookie_three);
return 0;
}
VC获取cookies的几种方法的更多相关文章
- VC++获取IDC_EDIT的7种方法
VC++获取IDC_EDIT的7种方法 http://blog.csdn.net/baizengfei/article/details/7997618 //第一种方法 int number1, num ...
- PHP中获取星期的几种方法
PHP中获取星期的几种方法 PHP星期几获取代码: 1 date(l); 2 //data就可以获取英文的星期比如Sunday 3 date(w); 4 //这个可以获取数字星期比如123,注意0 ...
- C#获取当前路径的7种方法
总结C#获取当前路径的7种方法 C#获取当前路径的方法如下: 1. System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName ...
- Java获取随机数的几种方法
Java获取随机数的几种方法 .使用org.apache.commons.lang.RandomStringUtils.randomAlphanumeric()取数字字母随机10位; //取得一个3位 ...
- spring 获取 WebApplicationContext的几种方法
spring 获取 WebApplicationContext的几种方法 使用ContextLoader WebApplicationContext webApplicationContext = C ...
- Struts2 后台获取路径的几种方法
Struts2 后台获取路径的几种方法 package actions.app; import java.io.File; import org.apache.struts2.ServletActio ...
- 体温数据上传程序开发+获取时间的三种方法+DB Browser下载及安装
今天开始了体温上传程序的开发 今日所学: 获取时间 (21条消息) (转)安卓获取时间的三种方法_sharpeha的博客-CSDN博客_安卓获取时间 DB Browser安装教程 (20条消息) sq ...
- VC调用javascript的几种方法
第一种:通过execScript调用.这种方法,虽然操作方便,但不能获取返回值.m_spHtmlDoc->get_parentWindow(&m_pHtmlWindow);VARIANT ...
- VC++ 响应回车键的2种方法
众所周知,VC++响应回车键经常用的方法是利用 BOOL PreTranslateMessage(MSG* pMsg) 截取回车键消息,如: if (pMsg->message == WM_KE ...
随机推荐
- 【汇编】2.第一个程序:hello world
前言 在上篇博文 [汇编]1.汇编环境的搭建:DOSBox的安装 中,我们完成了 1.汇编环境模拟器DOSBox的安装. 2.汇编编译相关程序MASM6的下载. 在上篇文章的最后我们提到了挂载DOS程 ...
- 「Vijos 1285」「OIBH杯NOIP2006第二次模拟赛」佳佳的魔法药水
佳佳的魔法药水 背景 发完了k张照片,佳佳却得到了一个坏消息:他的MM得病了!佳佳和大家一样焦急万分!治好MM的病只有一种办法,那就是传说中的0号药水--怎么样才能得到0号药水呢?你要知道佳佳的家境也 ...
- Java散点
1.在Java中,所有需要保存在常量池中的数据,长度最大不能超过65535,这当然也包括字符串的定义
- 查看磁盘型号和内存及raid信息
1.查看磁盘型号 工具:smartmontools #smartctl --help #smartctl --all /dev/sda -d megarid,1 (第一块磁盘的信息) #smartct ...
- KafkaProducer Sender 线程详解(含详细的执行流程图)
目录 1.Sender 线程详解 2.RecordAccumulator 核心方法详解 温馨提示:本文基于 Kafka 2.2.1 版本. 上文 <源码分析 Kafka 消息发送流程> 已 ...
- Have Fun with Numbers
Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, wit ...
- 【转】Java面试题:多继承
招聘和面试对开发经理来说是一个无尽头的工作,虽然有时你可以从HR这边获得一些帮助,但是最后还是得由你来拍板,或者就像另一篇文章“Java 面试题:写一个字符串的反转”所说: 面试开发人员不仅辛苦而且乏 ...
- 最小生成树kruskal 知识点讲解+模板
0.前言 因为本人太蒟了 我现在连NOIP的初赛都在胆战心惊 并且我甚至连最小生成树都没有学过 所以这一篇博客一定是最详细的QAQ 哈哈 请您认真看完如果有疏漏之处敬请留言指正 感谢! Thanks♪ ...
- mysql的查询优化
参考网站:http://www.liyblog.top/p/6 这里总结了52条对sql的查询优化,下面详细来看看,希望能帮助到你 1, 对查询进行优化,应尽量避免全表扫描,首先应考虑在 wh ...
- 真机调试报The executable was signed with invalid entitlements.错误
真机运行时,提示The executable was signed with invalid entitlements.(The entitlements specified in your appl ...