cookie 内容的获取
NSMutableArray *cookiesStoreAll = [[NSMutableArray alloc]init];
NSUInteger totalNumberOfCookies;
NSMutableURLRequest *request_get = [[[NSMutableURLRequest alloc] init] autorelease];
[request_get setURL:[NSURL URLWithString:urlStr]];
[request_get setHTTPMethod:@"GET"];
[request_get setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request_get setHTTPShouldHandleCookies:YES];
// doGet - response
NSHTTPURLResponse *response_get = nil;
NSError *error_get = nil;
NSData *responseData_get = [NSURLConnection sendSynchronousRequest:request_get returningResponse:&response_get error:&error_get];
NSString *data_get=[[NSString alloc]initWithData:responseData_get encoding:NSUTF8StringEncoding];
//get the cookies by using the header cookies
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
NSDictionary *headerFields_get = [(NSHTTPURLResponse*)response_get allHeaderFields];
NSURL *urlCookies_get = [NSURL URLWithString:urlStr];
NSArray *cookies_get = [NSHTTPCookie cookiesWithResponseHeaderFields:headerFields_get forURL:urlCookies_get];
// retrieve the cookies from url by sharedHTTPCookieStore
NSArray *cookiesUse_get = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:urlCookies_get];
NSUInteger numberOfCookiesUse_get = [cookiesUse_get count];
NSUInteger numberOfCookies_get = [cookies_get count];
NSLog(@"numberOfCookies_get==:%d", numberOfCookies_get);
for (NSHTTPCookie *cookie in cookies_get) {
NSLog(@"numberOfCookies_get :Name: %@ : Value: %@", cookie.name, cookie.value);
}
NSLog(@"numberOfCookiesUse_get==:%d", numberOfCookiesUse_get);
for (NSHTTPCookie *cookie in cookiesUse_get) {
NSLog(@"numberOfCookiesUse_get :Name: %@ : Value: %@", cookie.name, cookie.value);
}
// Cookie - add the array to the cookieStoreAll
[cookiesStoreAll addObjectsFromArray: cookiesUse_get];
totalNumberOfCookies = [cookiesStoreAll count];
//NSString *realCookieValue;
// get the needed cookie and convent to the NSString
for(int j=0; j<totalNumberOfCookies; j++) {
NSLog(@"numberOfCookiesUse_get==:%@", [[cookiesStoreAll objectAtIndex:j] name]);
NSLog(@"numberOfCookiesUse_get==:%@",[[cookiesStoreAll objectAtIndex:j] value]);
//NSString *realCookieName = [[cookiesStoreAll objectAtIndex:j] name];
//if([realCookieName isEqualToString: @"neededCookieName"])
//{
//realCookieValue = [[cookiesStoreAll objectAtIndex:j] value];
//cookiesString = [NSString stringWithFormat:@"neededCookieName=%@; ", realCookieValue];
//}
}
cookie 内容的获取的更多相关文章
- C++ 与 php 的交互 之----- C++ 获取 网页文字内容,获取 php 的 echo 值。
转载请声明出处! http://www.cnblogs.com/linguanh/category/633252.html 距离上次 谈 C++ 制作json 或者其他数据传送给 服务器,时隔两个多月 ...
- 内容页获取当前栏目的上一级栏目ID
发现V9在列表页可以用$parentid 得到当前栏目的父级ID,但在内容页这个函数的值却为空了,需要按下面的写法才行, V9 在内容页获取当前栏目的上一级栏目ID {$CAT[parentid]} ...
- cookie——创建、获取、删除
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- C#中在内容页获取其模板页中的变量,或者值
在CSDN的博文中看到了 muziduoxi 的文章:http://blog.csdn.net/muziduoxi/article/details/5386543 虽然里面提到的方法没有解决我的难题, ...
- Servlet实现禁用cookie重写URL获取session
前言 一个女人让他的程序员丈夫去商店买东西:你去附近的商店买些鸡蛋,如果有香蕉的话,买8个回来,这个丈夫买了8个鸡蛋回来,他的妻子大吃一惊:你为什么买了8个鸡蛋?! 程序员丈夫回答:因为他们有香蕉. ...
- 关于MFC文本框输入内容的获取 与 设置文本框的内容
八月要开始做界面了<( ̄︶ ̄)/,然而目前只会用MFC╮(╯▽╰)╭ 好吧,言归正传,设置好文本框后,要获取用户输入的内容,可以用: GetDlgItemText() ; 这个函数有两个参数,第 ...
- javascript获取iframe框架中页面document对象,获取子页面里面的内容,iframe获取父页面的元素,
javascript获取iframe框架中,加载的页面document对象 因为浏览器安全限制,对跨域访问的页面,其document对象无法读取.设置属性 function getDocument(i ...
- [转]javascript js cookie的存储,获取和删除
本文转自:http://www.jb51.net/article/13240.htm 使用方法: //1.存储Cookie //2.参数说明: 1.参数1:Cookie存储Name,参数2:Cooki ...
- Android初级教程之内容提供者获取联系人信息
内容提供折详细理论知识请参考之前的博文:http://blog.csdn.net/qq_32059827/article/details/51646513 这里新建了三个联系人信息,通过查看系统联系人 ...
随机推荐
- 终端执行python shell的方法
假设有一个Py文件,放在下PycharmProjects/learn下,文件名是 myfile.py. 1.打开终端输入python3进入2.在shell下 输入import sys 回车3.输入 s ...
- (07)odoo扩展API
* 打开XML-RPC 连接 >>> import xmlrpclib >>> srv, db = 'http://localhost:8069', ' ...
- 获取txt文件指定行内容
#!/usr/bin/python num=0; ni=open("C:\Python34\ceshi.txt") for line in ni: num=num+1; #表示行 ...
- 新建txt文件新增内容并打印出
#!/usr/bin/python import os file1=open("C:\Python34\ceshi.txt","a+"); #a+开一个文件用 ...
- hive分区导致FAILED: Hive Internal Error: java.lang.NullPointerException(null)
写了一条hive sql ,其中条件中存在 dt>=20150101 and dt<=20150228 这样的条件,原来执行没问题,今天就抛出 FAILED: Hive Internal ...
- SQL Server数据库(SQL Sever语言 函数以及SQL编程)
1.数学函数:操作一个数据,返回一个结果 --去上限: ceiling ☆select ceiling(price) from car --去下限:floor ☆select floor(price) ...
- easyui datagrid导出excel
[第十四篇]easyui datagrid导出excel <a class="btn btn-app" onclick="exportExcel()" ...
- c++实现之 -- 汉语词语的简单处理
好了,我们现在已经会怎样读入了,然后就是研究一下如何存储等一些细节上的的问题了. 首先,比较函数是不能传入char*的地址的,但是可以接受一个string类. 然而,如果是两个比较长的string类, ...
- Oracle 中的 decode
含义解释:decode(条件,值1,返回值1,值2,返回值2,...值n,返回值n,缺省值) 该函数的含义如下:IF 条件=值1 THEN RETURN(翻译值1)ELSIF 条件=值2 THEN R ...
- Linux下配置用msmtp和mutt发邮件
Linux下可以直接用mail命令发送邮件,但是发件人是user@servername,如果机器没有外网的dns,其他人就无法回复.此时,有一个可以使用网络免费邮箱服务的邮件发送程序就比较重要了.ms ...