Results 1 to 5 of 5

Thread: Find and click a hyperlink in a browser?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    Austin
    Posts
    397

    Find and click a hyperlink in a browser?

    System.Diagnostics.Process.Start("iexplore http://www.site.com")


    Using a winform how would you find and click a hyperlink on a page?

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Find and click a hyperlink in a browser?

    unless you have some way to hook into the external IE process to read the DOM, find the link, and then click on it, I don't know how you would do that.

    If you were to host the browser control in WinForms, it can easily be done, because the browser control can expose the DOM to your app, so you can manipulate it. See my signature for an example project on how to do that.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Find and click a hyperlink in a browser?

    You could just bypass that by requesting the contents of the page using HttpWebRequest, finding the hyperlink you want and calling iexplore to THAT URL!

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    Austin
    Posts
    397

    Re: Find and click a hyperlink in a browser?

    Using this code i was able to get all the HTML from the site.

    Code:
            Dim pr As New WebProxy
            pr.Credentials = CredentialCache.DefaultCredentials
            Dim wRequest As Net.WebRequest
            Dim wResponse As Net.WebResponse
    
            wRequest = Net.WebRequest.Create(URL)
            wRequest.Proxy = pr
            wResponse = wRequest.GetResponse
    
            Return New System.IO.StreamReader( _
            wResponse.GetResponseStream, _
            System.Text.Encoding.GetEncoding("utf-8")).ReadToEnd
    Code:
    <a href="http://www.AAA.com/search/redirect.php?f=http%3A%2F%2Fpagead2.xxxxxxxxx.com%2Fpagead%2Ficlk%3Fsa%3Dl%26ai%3DBmFISjt8UR_z9FpDYoQPl7cSGCqWd4DHtxZvBAsCNtwHgxQgQAhgCIOqdzAMoCjgAUMqOqyVgydbljOSk8BOgAZ_f4f4DsgELY294d2lmaS5jb23IAQHaARNodHRwOi8vY294d2lmaS5jb20vgAIBqAMB6AMN6AP-AugD2gLoA7cC9QNAAQAA%26num%3D2%26adurl%3Dhttp%3A%2F%2Fwww.xxxx.com%26client%3Dca-dp-sedo-04_xml&amp;l=ZjI1MDNkYzg2MGFhOGRlZTQ5NTU5OWI0YWZmYzMzNjEJMC4wNTk5CTQJMTMJMQkwCQkxMAkyCTAJYzU5YTA2NGQwMDIwNTA1MzI0NjUwNzkwNTAyMTU0NjAJd3d3LldpRmkuY29tCTMwMjgzNDczCWMJMTg3ODA4MgkwCTQJZnJlZSB3aWZpCTIzCTEJNQk1OQkwCTAuMDkwMDAwCU4JMAlhMDkyOTVkZjQ3NTA0YjFjYzhjNDNhZGQzODY0NzM0MwkwCTAJMA==" 
    class="aLink" 
    target="_blank" 
    onmouseout="window.status=''" 
    onmouseover="window.status=''; return true;">www.ABC.com</a>
    Any clue how i would gather the HTML from above and navigate to the URL in the string?

  5. #5
    Lively Member RickyH's Avatar
    Join Date
    Oct 2007
    Posts
    92

    Re: Find and click a hyperlink in a browser?

    Quote Originally Posted by kleinma
    See my signature for an example project on how to do that.
    I looked at your project to manipulate the axWebBrowser. Great functions by the way, i think ill see what i can do to use them. Here is a list of functions that I found in there:

    Code:
     GetTextboxText()
    SetTextareaText(txtData.Text)
    GetTextareaText()
    ClickNormalButton()
    ClickSubmitButton()
    GetLinks()
    ChangeDIVColor()
    ShowPageSource()
    ExecuteJavascript()
    PrintPage()
    GetImageInfo()
    GetComboValue()
    ClickCheckBox()
    I don't see a ClickLink function/Procedure just GetLinks. Closest I saw, and this might be workable, but please enlighten me is clickSubmitButton or ClickNormalButton.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width