Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8855653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:11:04+00:00 2026-06-14T14:11:04+00:00

Using a Webview, I would like to find the links inside this page. -(void)webView:(WebView

  • 0

Using a Webview, I would like to find the links inside this page.

-(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
    DOMDocument *myDOMDocument = [[self.webview mainFrame] DOMDocument];

looks like a good starting point, but I find the WebScriptObject Class Reference a little cryptic. Clearly I don’t want to evaluate some Javascript to get the links. I want to directly read the DOM.

How may I find which nodes in the DOM are links, and get the address they are pointing to ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:11:06+00:00Added an answer on June 14, 2026 at 2:11 pm

    Find the DOMNodes for images

    see walkNodeTree @ http://cocoadev.com/wiki/DOMCore

    — complete sample to find image nodes, get their src and make nsimages

    @implementation DDAppDelegate
    
    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
        [self.webview.mainFrame loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://dominik.pich.info/Home.html"]]];
    }
    
    -(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
        DOMDocument *myDOMDocument = [[self.webview mainFrame] DOMDocument];
    
        NSMutableArray *imgs = [NSMutableArray array];
        [self walkNodeTree:myDOMDocument imgsCollected:imgs];
    
        //bad code, demo
        NSMutableArray *nsImages = [NSMutableArray array];
        for (DOMNode *img in imgs) {
            for(int i = 0; i < img.attributes.length; i++) {
                DOMNode *attr = [img.attributes item:i];
                NSLog(@"%@", attr.nodeName);
                if([attr.nodeName.lowercaseString isEqualToString:@"src"]) {
                    NSString *urlstring = [attr nodeValue];
                    NSURL *url = [NSURL URLWithString:urlstring relativeToURL:[NSURL URLWithString:@"http://dominik.pich.info/"]];
                    NSImage *nsimg = [[NSImage alloc] initWithContentsOfURL:url];
                    if(nsimg)
                        [nsImages addObject:nsimg];
                }
            }
        }
    
        NSLog(@"%@", nsImages);
    }
    
    - (void)walkNodeTree:(DOMNode*)parent imgsCollected:(NSMutableArray*)imgs {
        DOMNodeList *nodeList = [parent childNodes];
        unsigned i, length = [nodeList length];
        for (i = 0; i < length; i++) {
            DOMNode *node = [nodeList item:i];
    
            NSLog(@"%@", node.nodeName);
            if([node.nodeName.lowercaseString isEqualToString:@"img"]) {
                [imgs addObject:node];
            }
            else {
                //recurse
                [self walkNodeTree:node imgsCollected:imgs];
            }
        }
    }
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to find a solution to allow my WebView still alive when
I load a web page by using WebView in my app and there are
I'm using a WebView in edit mode. I have implemented this method from WebUIDelegate
I would like to integrate Facebook into an application - enable login using Facebook
I would like to get a certain column from my sql database using the
I have this code and i would like to use asyncTask manager with this
Hello i am using this tutorial to set the spinwheel for my webview ,
I am using myWebview.getSettings().setBuiltInZoomControls(true); to set zoom controls on my webview. I realize this
In Qt Creator, the webview displays websites just like IE would. How can I
I'm using a webview on my activity. page is loaded from android_asset: webView.loadUrl(file:///android_asset/htm/main.htm); I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.