javascript - UIWebView retrieve a link and navigate to it -


I'm adding a UIWebView to my app, which should load the password-protected webpage. Automatically select a link from that page and navigate to that page. This website constantly changes, so there is no way to choose the intended page URL. I must first login and then select a link from the main page

After logging in for the desired link, how can I code and navigate to search my main page Am I

I think that will help. NSError * Error will handle NSError errors;

  // Create the URL for your page Http://example.com/index.php Just one example NSURL * pageURL = [NSURL URLWithString: @ "http://example.com/index.php"]; // Recover page regex to parse it by using NSString * pageHtml = [NSString stringWithContentsOfURL: PAGEURL encoding: NSUTF8StringEncoding error: & amp; Error]; If (error) {NSLog (@ "Error retrieving HTML:% @", error); // will terminate my app (); // TODO: handle the connection error here} error = zero; // Creating regex to parse // page html // You can easily find it. NSRegularExpression * regex = [[NSRegularExpression alloc] initWithPattern: @ "& lt; a [^ & gt;] * href = \" [[^ \ "] *) \" [^ & gt;] * & gt; MyLink & lt; / A & gt; "Option: NSRegularExpressionCaseInsensitive error: & amp; error; if (error) {NSLog (@" error while creating regex:% @ ", error); // will terminate your app;) TODO: handle regex error here } // Getting our first match of regex is to get the first group NSTextCheckingResult * match = [regex firstMatchInString: pageHtml option: 0 range: NSMakeRange (0, [pageHtml length])]; NSString * PAGEURL = [pageHtml substringWithRange: [Match rangeAtIndex: 1]]; NSLog (@ "Page URL =% @" PAGEURL), [WebView loadRequest: [NSURLRequest requestWithURL: [NSURL URLWithString: PAGEURL]]];   

With your UIWebView HTML From the Halle download page you can replace

  NSURL * PAGEURL = [NSURL URLWithString: @ "http://example.com/index.php"]; NSString * pageHtml = [NSString StringWithContentsOfURL: Page URL Encoding: NSUTF8StringEncoding Error: & amp; Error];   

With this:

  NSString * pageHtml = [Webview stringBuViewting JavaScriptFrameString: @ "Document.body.innerHTML"];    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -