Results 1 to 6 of 6

Thread: VB.NET -> Search in HTML class ?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    176

    VB.NET -> Search in HTML class ?

    EDIT: I'm using Visual Basic 2008

    Hi.

    Is it possible for VB.NET to search in a HTML class?

    Because I'm making a program that will click on a link in a class called "click" and in the class there is a link (href) that wan't my program to click on.

    So simply, I wan't my program to search in the class "click" after a href and then click on it.

    Or, if it's more easy, it could give me the value of the link. ( This one would be better for me, because then I could collect some info from it ).

    If you wonder why I need this program I can explain:

    I work in PHP for most of my time, and now I'm creating a website and a game, and a cPanel for the users. To controll everything it would be more effectiv if I had a "remote control", and thats what I'm building in VB.Net.

    // Kevin
    Last edited by worqy; May 15th, 2010 at 01:13 PM.
    PHP Code:
    $im_addicted_to_programming true

  2. #2
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: VB.NET -> Search in HTML class ?

    Code:
    Using wc As New Net.WebClient()
         Dim sr As New IO.StreamReader(wc.OpenRead("http://mywebsite.com/mypage.html"))
         Dim html As String = sr.ReadToEnd()
         sr.Close() : sr.Dispose()
         Dim re As New System.Text.RegularExpressions.Regex("(?<=\<a.+?href="")[^""]+""(?=.+?class=""?click)")
         MessageBox.Show(re.Match(html).Value)
    End Using
    This works if the href attribute comes before the class attribute and the link is surrounded in quotes, which it should be, if the first/only defined class is click, and if the link is not javascript-based.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    176

    Re: VB.NET -> Search in HTML class ?

    No this does not work for me. Any other suggestions?
    PHP Code:
    $im_addicted_to_programming true

  4. #4
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: VB.NET -> Search in HTML class ?

    Any reason why? Does it throw an exception? Doesn't show anything? Your website's link has a JavaScript onclick or onmousedown/up? It doesn't read the page properly? The regular expression isn't right? You need to display all the links, not just one? It's not in the format I specifically said would be the only working one for that particular Regex?

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    176

    Re: VB.NET -> Search in HTML class ?

    It does show something, a empty msgbox.
    Why? I don't know.

    I'm just searching for one link in a class, there is some text in the class before the link comes. But in that class there is just one link.
    PHP Code:
    $im_addicted_to_programming true

  6. #6
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: VB.NET -> Search in HTML class ?

    One link... in a class? I thought it was the other way around... you do mean the class= attribute, right?

    Can you post the relevant part of the source HTML, please?

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