Hello!

Yes, This is my first post. And it might seem a little selfish that i just joined to ask a question, so don't worry, i'm not gonna ask and run, i'll stick around.

So my problem, what im trying to do is using regex i'm pulling information from a webpage, and they are shown on a checklist. I want to be able to check the check on the checklist, press a button and ill be taken to the place the regex text was, or a <div> tag around there.

Something i've also wondered about is if your able to link the regex to a in-software Webbrowser from the tool box, as i'm trying to pull information from a site that requires me to log in, before i can view the certain page. So i just wnat to be able to log in Webbrowser1 and then the regex can read from there.

Thank you in advance, and i'm looking forward to being a part of this community.

Recommended Answers

All 12 Replies

I'm gonna bump this, sorry if it's not allowed.

I'm not quite clear on your question.
..Are you trying to login a website?
..Scroll to a section in the webpage that has been loaded in your vb.net WebBrowser?
..OR just extract the data from a certain section when an item is checked in your CheckedListBox?

Btw, if you are guilty for joining DaniWeb just to ask a question or two, then I am guilty for joining DaniWeb to answer a question, or two.:D

Haha :) Sorry i'm kinda new to VB.NET it's kinda hard to explain (Lame excuse) I'll try and explain in a better way, and just ask one question. I'll also fix up the main thread.

"Question: How do i scroll to an Html element (and have it centered) on a webpage loaded in my VB.NET WebBrowser?"

Hopefully these "Html elements" have "names".
For instance, when viewing a webpage's HTML source code, and you locate something similar to:

<div class="shade"> <div class="right"> <a href="/forums/post1433269.html#post1433269" id="postcount1433269" [B]name="4"[/B]>Permalink</a>  </div>   1 Minute Ago

..you have to locate the "name=..." part of the HTML and simply add a "#" and the name, just following the original link of the page.
Example:
http://www.daniweb.com/forums/thread335165.html#4

This usually targets an area of the webpage and scrolls it to the very top of the browser.

If you cannot locate the "name" of something and/or would like to "center" the content of the webpage in the WebBrowser instead of scrolling it to the top, you will have to modify the WebBrowser "DomDocument" and insert "names" in certain locations of the page to use and target.

I personally have not done much, if any DomDocument webpage editing, but hopefully this link might give you an idea on how to get started.

OH thank you! I see how that works, it's actually just like css. But as an additional question, What do i do if there are several HTML elements with the same Name, and there are absolutely no differences between them?

Check out this link for a better idea on how to modify the webpage inside the WebBrowser.

Good luck with the rest.:)

EDIT:
Just wanted to add.
Why not extract the HTML and only display the selections in the WebBrowser?

That is actually a good idea, If i did that it would mean i could do the whole webbrowser thing without actually having the webbrowser right, it would just click the links ect..? OH and again, thank you for your help!

See if this helps.
1 TextBox (MultiLine), 1 Button.

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = getUrlPageContent("http://www.daniweb.com/forums/post1433319.html")
    End Sub
    Function getUrlPageContent(ByVal url As String) As String
        Try
            Dim connect As Net.HttpWebResponse = CType(Net.HttpWebRequest.Create(url).GetResponse, Net.HttpWebResponse) '// connect.
            Dim content As IO.Stream = connect.GetResponseStream()
            Dim reader As New IO.StreamReader(content)
            Dim htmlContent As String = reader.ReadToEnd
            reader.Close() : content.Close() : connect.Close()
            Return htmlContent
        Catch ex As Exception
            MsgBox("There was a connection problem...", MsgBoxStyle.Critical)
            Return Nothing
        End Try
    End Function
End Class

Thank you very much, you have helped me alot! But one more question... Then you can slaughter the Giraffe... The second link you gave didn't really seem to give me information on how i would navigate to a HTML element, if they have the same name.. :)
Very, very last question ;)

If by "slaughtering a Giraffe", you mean poke it's eyes out, then I'm out of luck. Too short and I only have a step ladder.:D
Although, one time, I was in a tree, hiding behind a leaf, and had a 50 foot ladder to poke a giraffe's eyes with:D, but that another story and probably the wrong forum for.

..The last link I have posted, was to give you an idea on how to modify the WebBrowser's content.
First you would have to replace all the similar names with your own, then probably save the content to a file somehow, and load that file with the File's location and the "#some name".
You might also have to replace links within the file saved, for example, a link that is <a href="/somepage/etc.">, might have to be saved w/the URL of the page you are currently viewing, as: <a href="http://www.somesite.com/somepage/etc.">.

As mentioned previously, I have not done much/if any DomDocument editing, but the info I have provided so far for this thread should give you a good start.

THank you very much :) I'll mark this as solved now!

As previously mentioned, you can locate the "names" of HTML Elements to Target a section of a page, although, I have recently discovered that you can also Target the "id" of an HTML Element.

Hope this helps anyone searching for a similar solution.:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.