그렇게 많은 시간 삽질하지 않고 알게된 Get 방식을 이용한 html 코드 크로울링 소스

- (void)applicationDidFinishLaunching:(UIApplication *)application {   
    NSString* str = [self GetGnamjaStr];
    NSData* htmlData = [str dataUsingEncoding:-2147481280];
    [webview loadData:htmlData MIMEType:@"text/plain" textEncodingName:@"EUC-KR" baseURL:nil];      
    [window makeKeyAndVisible];
}

-(NSString*)GetGnamjaStr {
    NSError *error;
    NSURLResponse *response;
    NSData *dataReply;
    NSString *stringReply;
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: [NSURL URLWithString: [NSString stringWithFormat:@"http://사이트주소"]]];
    [request setHTTPMethod: @"GET"];
    dataReply = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
    stringReply = [[NSString alloc] initWithData:dataReply encoding:-2147481280];
    return stringReply;
}

소스 보시면 알겠지만 리퀘스트하고 스트링으로 받고 웹뷰에 뿌리는 것을 알 수 있음.
인코딩 관련 부분은 한글페이지 긁는 용도로 파라미터 조정함.

스트링 처리는 기회되면 나중에~~
활용은 알아서~
2009/01/06 18:00 2009/01/06 18:00

댓글을 달아 주세요