发送http请求get方法

//获取网页html
        NSURL* url = [NSURL URLWithString:@"http://www.baidu.com"];
        NSMutableURLRequest* request = [NSMutableURLRequest new];
        [request setURL:url];
        [request setHTTPMethod:@"GET"];
        NSURLRequest* response;
        NSData* data = [NSURLConnection sendSynchronousRequest:request
                                             returningResponse:&response error:nil];
        NSString* strRet = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
         NSLog(strRet);    
         [strRet release];

  

posted @ 2013-07-26 11:12  蓬莱仙羽  阅读(440)  评论(0)    收藏  举报