locked
Extracting text from a webpage RRS feed

  • Question

  • Hi. Im looking for a way to extract text from a webpage and save it to a text file or database. Im just a beginning programmer so i dont know too much about HTML code or anything like that. Any help i could get would be greatly appreciated. The website that I'm trying to extract the text from is http://www.corruptsource.com/timeframe.php?server=6. This website has been down often recently so id like to add an update button so that when clicked it attempts to read the text from the columns in the website and preferrably update a database with the information. There are only two pieces of information that i need from this website and that is from the Time Last Killed and Last Killed By columns. it needs to search for the names in the first column and match them to the database and update the appropriate columns. Thank you in advance for any help on this.
    Monday, November 23, 2009 9:12 AM

Answers


  • Alright, URL that you gave does not all direct linking to it, must be opened inside their iframe, however, they are providing another link for the same page. I'm using it.

    You'll need a webrowser on your form, a richtextbox [should be pretty wide] and 3 buttons. Do not change names and paste this code.

    I'm printing contents of Names just to show it. You can extract it one by one, compare in database, fire queries.. etc..

    also, I didnt get what exactly this data shows and why you want that, it may have something you do not want. If its like that, just point it out.

    Public Class Form1
    
        Structure tableData
            Dim lastKilledBy As String
            Dim time As String
        End Structure
    
        Dim names As New Dictionary(Of String, tableData)
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            WebBrowser1.Navigate("http://www.corruptsource.com/Timeframe.php?server=quiver&fs=yes")
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            'Click after the document is loaded
            Dim rows As HtmlElementCollection
            rows = WebBrowser1.Document.GetElementsByTagName("table")(1).GetElementsByTagName("tr")
    
            For i = 1 To rows.Count - 1
                Dim row As HtmlElement
                row = rows(i)
    
                If row.GetElementsByTagName("td").Count > 1 Then
                    Dim god, lastKilledBy, killedTime As String
                    god = row.GetElementsByTagName("td")(0).InnerText
                    lastKilledBy = row.GetElementsByTagName("td")(1).InnerText
                    killedTime = row.GetElementsByTagName("td")(2).InnerText
    
                    Dim tempData As tableData
    
                    tempData.lastKilledBy = lastKilledBy
                    tempData.time = killedTime
    
                    If names.Keys.Contains(god) Then
    
                        names(god) = tempData
                    Else
                        names.Add(god, tempData)
                    End If
                End If
            Next
            MsgBox("Working Done, Click button3")
            'now names has all the information you need
    
        End Sub
    
        Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            For Each key As String In names.Keys
                RichTextBox1.AppendText(key & ":" & names(key).lastKilledBy & ":" & names(key).time & vbCrLf)
            Next
        End Sub
    End Class

    Thanks

    My BlogMy FacebookYOUR Place to have fun time ! Awesome RPG Action Game
    • Proposed as answer by Omie Wednesday, November 25, 2009 9:05 AM
    • Marked as answer by Martin Xie - MSFT Friday, November 27, 2009 12:13 PM
    Wednesday, November 25, 2009 7:19 AM

  • You can simple Set Visibility property of that webbrowser to false. but then you need to start work from webrbowser's document completed event. That is to start work after document is loaded. but it gets messy sometimes. use try-catch.

    something like-


    sub document_completed handles webbrowser1.documentcompleted
      workSubroutine()
    end sub

    workSubroutine()
     Try
      'code from button2.click
     Catch
     EndTry
    End sub


    Thanks

    My BlogMy FacebookYOUR Place to have fun time ! Awesome RPG Action Game
    • Proposed as answer by Omie Wednesday, November 25, 2009 9:05 AM
    • Marked as answer by Martin Xie - MSFT Friday, November 27, 2009 12:13 PM
    Wednesday, November 25, 2009 7:48 AM

All replies

  • I can not visit the website:"http://www.corruptsource.com/timeframe.php?server=6", but I suggest you use System.Text.RegularExpressions.Regex to extract text from it.


    ____________________________
    April
    http://www.comm100.com/livechat/
    Tuesday, November 24, 2009 11:40 AM
  • Try the code below, this is not full code for your question but this will read the webpage source code line by line and return it as string . Then you can use regular expression or string contains method to search for the text and extract it.

    Imports System.Net
        Public Function readWebpageSourceTag(ByVal webLink As String) As String
            Dim WebSite As Uri = New Uri(webLink)
            Dim Webreq As WebRequest = WebRequest.Create(WebSite)
            Dim Webresp As WebResponse = Webreq.GetResponse
            Dim Webstr As Stream = Webresp.GetResponseStream
            Dim sr As StreamReader = New StreamReader(Webstr)
            Dim t As String = sr.ReadToEnd      
           sr.Close()       
           Webstr.Close()
            Return t
        End Function
    If you have question about regular expression, you can post your question at http://social.msdn.microsoft.com/Forums/en-US/regexp/threads

    kaymaf
    If that what you want, take it. If not, ignored it and no complain
    Wednesday, November 25, 2009 1:15 AM
  • thanks. at the very least id like to extract the text in the table on the webpage and then save it to a .txt file. if i can have this as a process running in the background without actually opening the webpage that would be the best. i know enough of coding to know how to read and write to a txt file but getting the info off of the page is where im having the problem. another issue im having is that the webpage has been down a lot lately but there is another page that i could get the info off of. the problem is that one page lists the basic info but in order to get the last bit of info i need i need to click on a couple of links in order to get to the info. corruptsource is back up now so if someone could check it out and let me know that would be great. im going to check into the help ive been given so far and see if i can get that to work for me. thanks.
    Wednesday, November 25, 2009 1:25 AM
  • Why are you talking about webpages here?

    Direct then to the www.asp.net foums.

    Renee
    Wednesday, November 25, 2009 2:44 AM
  • because im actually trying to program with vb.net and i have no clue how to use asp
    Wednesday, November 25, 2009 2:45 AM
  • ASP uses vb.net. Your question is a web question. Take it to the experienced people.

    Renee

    • Edited by Renee Culver Wednesday, November 25, 2009 3:25 AM
    Wednesday, November 25, 2009 2:51 AM
  • ok. i will ask them. but anyone else who has any suggestions as to how i might perform this task please let me know.
    Wednesday, November 25, 2009 2:56 AM
  • hmmm. all i want to do is have my program take text from a webpage and save it to a .txt file. i dont want to make a webpage or anything like that.
    Wednesday, November 25, 2009 3:25 AM
  • Explorer will do it to cut and paste after all it is WYSIWIG but I never have figured out how to do it the way you want to.

    Renee
    Wednesday, November 25, 2009 3:53 AM
  • thank you both for the code suggestions. ill check them out and see how they work with my app. ill let you know how it goes.
    Wednesday, November 25, 2009 5:26 AM
  • heres what the above code gave me.

    <html>
    <title>
    Corruptsource
    </title>
    <head>
    <link rel="stylesheet" href="common.css" type="text/css">
    <link rel="SHORTCUT ICON" href="tfo/favicon.ico" />
    <STYLE TYPE="text/css">
    .c1{
    background-color:#000000;
    text-indent:30px;
    color: #E0E0E0;
    }
    .bg1 {
      background-image: url("/title.gif");
      background-position: 50% 50%;
      background-repeat: no-repeat;
    }

    .c3{
    background-color:#000000;
    text-indent:0px;
    color: #E0E0E0;
    }
    #fullheight{height:100%}
    a {
    text-decoration:underline;
    color:#E0E0E0;
    }
    html,body{
          margin:0;
          padding:0;
          height:100%;
          border:none
       }
    .c2{
    text-decoration:underline;
    color:#E0E0E0;
    }
    a:visited {
    text-decoration: none;
    color: #E0E0E0;
    }
    a:hover {
        text-decoration: underline;
        color: #E0E0E0;
    }
    a:active {
        text-decoration:line-through;
        color: #E0E0E0;
    }

    </STYLE>
    <script language="javascript" type="text/javascript">
    <!--
    function navads() {
    document.getElementById('mainframe').style.height = "100%";
    frames['ads0'].location.href = "ad.php?ad=0";
    frames['ads1'].location.href = "ad.php?ad=1";
    }
    function navads1() {
    document.getElementById('mainframe').style.height = "100%";
    frames['ads0'].location.href = "ad.php?ad=0";
    frames['ads1'].location.href = "ad.php?ad=1";
    }
    </script>
    </head>
    <body style="background-color:Black;"  onload="document.getElementById('mainframe').style.height =
    mainframe.document.body.scrollHeight + 5">
    <table Width="100%" height=150 border=0">
    <TR>
    <td Height=175 width=100% class="bg1" valign=top align=right style="vertical-align:top; text-align:right">
    <iframe name="ads0" id="ads0" src="ad.php?ad=0" width=100% height=150 frameborder=0 tyle="FILTER: chroma(color=#FFFFFF)" allowtransparency="true"></iframe>
    </td>
    </tr>
    </table>
    <table Width="100%" height=100% border=0 align="center">
    <tr>
    <td Width=14% style="background-color:#585858 ;" valign="top">
    <div class=c2><a href="http://www.corruptsource.com">Home</a></div>
    <div class=c2><a onclick="javascript:navads()" href="shout.php" target="mainframe">ShoutBox</a></div>
    <div class=c2><a onclick="javascript:navads1()" href="http://webchat.quakenet.org/?nick=corrupt[4117]&channels=Milfhunterco" target="mainframe">Talk To Me</a></div>
    <div class=c2>TimeFrame</div>
    <div class="c1">- <a onclick="javascript:navads()" href="http://www.corruptsource.com/Timeframe.php?server=sigil" target="mainframe">Sigil</a><br></div>
    <div class="c1">- <a onclick="javascript:navads()" href="http://www.corruptsource.com/Timeframe.php?server=torax" target="mainframe">Torax</a><br></div>
    <div class="c1">- <a onclick="javascript:navads()" href="http://www.corruptsource.com/Timeframe.php?server=fabar" target="mainframe">Fabar</a><br></div>
    <div class="c1">- <a onclick="javascript:navads()" href="http://www.corruptsource.com/Timeframe.php?server=zimbob" target="mainframe">Zimbob</a><br></div>
    <div class="c1">- <a onclick="javascript:navads()" href="http://www.corruptsource.com/Timeframe.php?server=rancid" target="mainframe">Rancid</a><br></div>
    <div class="c1">- <a onclick="javascript:navads()" href="http://www.corruptsource.com/Timeframe.php?server=quiver" target="mainframe">Quiver</a><br></div>
    <div class="c3">---------------</div>
    <div class="c1">- <a onclick="javascript:navads()" href="http://www.corruptsource.com/Timeframe.php?login=1" target="mainframe">Login</a><br></div>
    </div>
    <div class=c2>RaidBar</div>
    <div class="c1">- <a onclick="javascript:navads()" href="raidap/Login.php">Login</a><br></div>       
    <div class="c1">- <a onclick="javascript:navads()" href="getinfo.php?results=rbtos" target="mainframe" target="mainframe">ToS</a><br></div>
    <div class="c1">- <a onclick="javascript:navads()" href="getinfo.php?results=rb" target="mainframe">Buy</a><br></div>
    </div>
    <div class="c2">GodSpotter</div>   
    <div class="c1">- <a onclick="javascript:navads()" href="getinfo.php?results=gs" target="mainframe" target="mainframe">About</a><br></div>
    <div class="c1">- <a onclick="javascript:navads()" href="getinfo.php?results=gstos" target="mainframe" target="mainframe">ToS</a><br></div>
    <div class="c1">- <a onclick="javascript:navads()" href="getinfo.php?results=gspost" target="mainframe">Buy</a><br></div>
    </div>
    <table Width="100%" height=150 border=0">
    <TR><br><center>
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_s-xclick">
    <input type="hidden" name="hosted_button_id" value="7880739">
    <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
    <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
    </form></center>

    <td Height=175 width=100% class="bg1" valign=top style="vertical-align:top; text-align:left">
    <iframe name="ads1" id="ads1" src="ad.php?ad=1" align=left width=100% height=150 frameborder=0 scrolling=no tyle="FILTER: chroma(color=#FFFFFF)" allowtransparency="true"></iframe>
    </td>
    </tr>
    </table>
    </td>
    <td Width=86% style="background-color:#585858 ;" valign="top">
    <iframe frameborder=0 id=mainframe name=mainframe height=100% width=100% onload="document.getElementById('mainframe').style.height =
    mainframe.document.body.scrollHeight" src="http://www.corruptsource.com/Timeframe.php?server=6"></iframe>
    </td>
    </table>



    here's the info that i need


    Devourer †Dark Kingdom† (Raid ) 11-23-09 02:20 pm 11-24-09 08:20 am 11-24-09 08:20 pm 2 Hours 37 Min Died Today
    Freezebreed, The Frozen Manipulator -Espada- (Raid ) 11-23-09 08:34 pm 11-24-09 02:34 pm 11-25-09 02:34 am 8 Hours 51 Min Died Today
    Crane •Därk Dynäs†y• (Raid ) 11-22-09 04:29 pm 11-24-09 04:29 am 11-25-09 04:29 am 10 Hours 46 Min Died Today
    Brutalitar, Lord of the Underworld Whoremonger (Raid ) 11-22-09 08:14 pm 11-24-09 08:14 am 11-25-09 08:14 am 14 Hours 31 Min Died Today
    Lord Sibannac |Heaven N ____| (Raid ) 11-21-09 03:17 pm 11-23-09 09:17 pm 11-25-09 09:17 am 15 Hours 34 Min Died Today
    Nessam ~~Halo~~Elites~~ (Raid ) 11-22-09 09:55 pm 11-24-09 09:55 am 11-25-09 09:55 am 16 Hours 12 Min Died Today
    Rotborn, Eater of the Dead -Espada- (Raid ) 11-22-09 11:30 pm 11-24-09 11:30 am 11-25-09 11:30 am 17 Hours 47 Min Died Today
    Lady Chaos, Queen of the Abyss -= Misfitz =- (Raid ) 11-21-09 07:18 pm 11-24-09 01:18 am 11-25-09 01:18 pm 19 Hours 35 Min Died Today
    Melt Bane, The Forbidden Demon Dragon -= Misfitz =- (Raid ) 11-23-09 03:33 am 11-24-09 03:33 pm 11-25-09 03:33 pm 21 Hours 50 Min Died Today
    Samatha Dark-Soul • Terror Society • (Raid ) 11-22-09 12:34 am 11-24-09 06:34 am 11-25-09 06:34 pm 24 Hours 51 Min Died Today
    Numerocure, The Black Messenger of Evil -= Misfitz =- (Raid ) 11-22-09 01:29 am 11-24-09 07:29 am 11-25-09 07:29 pm 25 Hours 46 Min Died Today
    Traxodon the Plaguebringer †Dark Kingdom† (Raid ) 11-22-09 11:35 am 11-24-09 05:35 pm 11-26-09 05:35 am 35 Hours 52 Min Died Today
    Jazzmin, Maiden of Vitality ~Heaven N ____~ (Raid ) 11-21-09 02:24 pm 11-24-09 02:24 pm 11-26-09 02:24 pm 44 Hours 41 Min Died Today
    Quiver, The Renegade ~Heaven N ____~ (Raid ) 11-20-09 12:06 pm 11-24-09 06:06 am 11-26-09 06:06 pm 48 Hours 23 Min Died Today
    Hackerphage, Protector of the Gateway Whoremonger (Raid ) 11-21-09 07:35 pm 11-24-09 07:35 pm 11-26-09 07:35 pm 1 Hours 52 Min Died Today
    Tylos, The Lord Master Temptation (Raid ) 11-23-09 08:04 am 11-24-09 08:04 pm 11-25-09 08:04 pm 2 Hours 21 Min Died Today
    Pinosis Temptation (Raid ) 11-23-09 09:01 am 11-24-09 09:01 pm 11-25-09 09:01 pm 3 Hours 18 Min Died Today
    Dreg nor, Keeper of the Infernal Essence Whoremonger (Raid ) 11-22-09 03:08 pm 11-24-09 09:08 pm 11-26-09 09:08 am 3 Hours 25 Min Died Today
    Threk, King of Lords FREEDOM (Raid ) 11-22-09 03:57 pm 11-24-09 09:57 pm 11-26-09 09:57 am 4 Hours 14 Min Died Today
    Synge, The Red Dragon One Love (Raid ) 11-24-09 04:57 am 11-24-09 10:57 pm 11-25-09 10:57 am 5 Hours 14 Min Died Today
    Lord Narada • Terror Society • (Raid ) 11-23-09 11:55 am 11-24-09 11:55 pm 11-25-09 11:55 pm 6 Hours 12 Min Died Today
    Lord Xordam -= Misfitz =- (Raid ) 11-22-09 12:45 am 11-25-09 12:45 am 11-27-09 12:45 am 7 Hours 2 Min Died Today
    Lord Varan Dont taze me, bro! (Raid ) 11-24-09 06:54 am 11-25-09 12:54 am 11-25-09 12:54 pm 7 Hours 11 Min Died Today
    Baron Mu, Dark Rider of the Undead Dont taze me, bro! (Raid ) 11-24-09 07:29 am 11-25-09 01:29 am 11-25-09 01:29 pm 7 Hours 46 Min Died Today
    Terrance, Rebel of Rallis †Dark Kingdom† (Raid ) 11-22-09 07:37 pm 11-25-09 01:37 am 11-26-09 01:37 pm 7 Hours 54 Min Died Today
    Bloodchill the Grizzly |Heaven N ____| (Raid ) 11-22-09 07:38 pm 11-25-09 01:38 am 11-26-09 01:38 pm 7 Hours 55 Min Died Today
    Lady Ariella Whoremonger (Raid ) 11-22-09 08:18 pm 11-25-09 02:18 am 11-26-09 02:18 pm 8 Hours 35 Min Died Today
    Tsort |-_-| (Raid ) 11-23-09 02:22 pm 11-25-09 02:22 am 11-26-09 02:22 am 8 Hours 39 Min Died Today
    Garland, The Lord Keeper Temptation (Raid ) 11-24-09 08:47 am 11-25-09 02:47 am 11-25-09 02:47 pm 9 Hours 4 Min Died Today
    Vitkros, Hydra of the Deep Temptation (Raid ) 11-24-09 09:41 am 11-25-09 03:41 am 11-25-09 03:41 pm 9 Hours 58 Min Died Today
    Murderface • Terror Society • (Raid ) 11-22-09 11:59 pm 11-25-09 05:59 am 11-26-09 05:59 pm 12 Hours 16 Min Died Today
    Ganja the Stone Golem |Heaven N ____| (Raid ) 11-23-09 03:07 am 11-25-09 09:07 am 11-26-09 09:07 pm 15 Hours 24 Min Died Today
    Hyrak, Bringer of Nightmares XxDisembodiedxX (Raid ) 11-23-09 10:25 pm 11-25-09 10:25 am 11-26-09 10:25 am 16 Hours 42 Min Died Today
    Mistress of the Sword ##ARGYBOYZ## (Raid ) 11-23-09 10:56 pm 11-25-09 10:56 am 11-26-09 10:56 am 17 Hours 13 Min Died Today
    Lord Suka †Heaven N ____† (Raid ) 11-22-09 10:57 am 11-25-09 10:57 am 11-27-09 10:57 am 17 Hours 14 Min Died Today
    Rancid, Lord of Thugs .:Blood Fathom:. (Raid ) 11-23-09 11:43 pm 11-25-09 11:43 am 11-26-09 11:43 am 18 Hours 0 Min Died Today
    Nar Zhul, Slayer of All ##ARGYBOYZ## (Raid ) 11-21-09 10:10 pm 11-25-09 04:10 pm 11-28-09 04:10 am 22 Hours 27 Min Died Today
    Smoot the Yeti |Heaven N ____| (Raid ) 11-23-09 04:33 pm 11-25-09 10:33 pm 11-27-09 10:33 am 28 Hours 50 Min Died Today
    Shadow .:FaTaL DeToX:. (Raid ) 11-24-09 03:05 pm 11-26-09 03:05 am 11-27-09 03:05 am 33 Hours 22 Min Died Today
    Gnorb A Crew (Raid ) 11-24-09 03:07 pm 11-26-09 03:07 am 11-27-09 03:07 am 33 Hours 24 Min Died Today
    The Emerald Assassin ~~Halo~~Elites~~ (Raid ) 11-24-09 12:17 am 11-26-09 06:17 am 11-27-09 06:17 pm 36 Hours 34 Min Died Today
    Great Lord Ganeshan †Heaven N ____† (Raid ) 11-22-09 06:41 pm 11-26-09 12:41 pm 11-29-09 12:41 am 42 Hours 58 Min Died Today
    Anguish •Pulse• (Raid ) 11-24-09 07:47 am 11-26-09 01:47 pm 11-28-09 01:47 am 44 Hours 4 Min Died Today
    Ag Nabak the Abomination †Heaven N ____† (Raid ) 11-22-09 07:57 pm 11-26-09 01:57 pm 11-29-09 01:57 am 44 Hours 14 Min Died Today
    Sigil, Lich of Woe ~Heaven N ____~ (Raid ) 11-23-09 12:33 am 11-26-09 06:33 pm 11-29-09 06:33 am 48 Hours 50 Min Died Today
    King Ashnar, Lord of the Unliving ##ARGYBOYZ## (Raid ) 11-23-09 08:38 pm 11-26-09 08:38 pm 11-28-09 08:38 pm 50 Hours 55 Min Died Today
    Detox • Terror Society • (Raid ) 11-24-09 04:16 pm 11-26-09 10:16 pm 11-28-09 10:16 am 52 Hours 33 Min Died Today
    Zertan, The Collector •ExoÐus• (Raid ) 11-24-09 01:46 am 11-27-09 01:46 am 11-29-09 01:46 am 56 Hours 3 Min Died Today
    Skybrine The Inescapable Noobs On Tour [L] (Raid ) 11-22-09 04:38 pm 11-27-09 04:38 am 11-30-09 04:38 am 58 Hours 55 Min Died Today
    Emperor Neudeus, Controller of the Universe •Pulse• (Raid ) 11-22-09 10:25 am 11-27-09 04:25 pm 12-01-09 04:25 am 70 Hours 42 Min Died Today
    Howldroid, Tormentor of the Pit •Pulse• (Raid ) 11-24-09 07:27 am 11-28-09 01:27 am 11-30-09 01:27 pm 79 Hours 44 Min Died Today
    Slashbrood, Devourer of the Blackness Whoremonger (Raid ) 11-24-09 12:49 pm 11-29-09 12:49 am 12-02-09 12:49 am 103 Hours 6 Min Died Today
    Kro Shuk, Doomslayer †Heaven N ____† (Raid ) 11-24-09 05:25 am 12-01-09 05:25 pm 12-06-09 05:25 pm 167 Hours 42 Min Died Today

    Please update or kill These gods
    Ebliss, Fallen Angel of Despair Noobs On Tour [L] (Raid ) 11-21-09 11:37 am 11-22-09 05:37 am 11-22-09 05:37 pm Died Today
    Windstrike The Vile Main Event [U] (Raid ) 11-09-09 02:33 am 11-16-09 02:33 pm 11-21-09 02:33 pm Died Today

    Wednesday, November 25, 2009 6:00 AM

  • I got lastkilled time column, confused which column to extract for LastKilledBy. Could you tell me exact names of columns as they are in webpage please ?

    am almost done with code..


    Thanks

    My BlogMy FacebookYOUR Place to have fun time ! Awesome RPG Action Game
    Wednesday, November 25, 2009 6:51 AM
  • oh thank you so much.
    God | Last killed by | Time Last Killed | Time Frame Start | Time Frame End | Time Remaining

    and i only need to pull the text from the first 3 columns because my program will auto calculate the last 3.
    Wednesday, November 25, 2009 6:55 AM

  • Alright, URL that you gave does not all direct linking to it, must be opened inside their iframe, however, they are providing another link for the same page. I'm using it.

    You'll need a webrowser on your form, a richtextbox [should be pretty wide] and 3 buttons. Do not change names and paste this code.

    I'm printing contents of Names just to show it. You can extract it one by one, compare in database, fire queries.. etc..

    also, I didnt get what exactly this data shows and why you want that, it may have something you do not want. If its like that, just point it out.

    Public Class Form1
    
        Structure tableData
            Dim lastKilledBy As String
            Dim time As String
        End Structure
    
        Dim names As New Dictionary(Of String, tableData)
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            WebBrowser1.Navigate("http://www.corruptsource.com/Timeframe.php?server=quiver&fs=yes")
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            'Click after the document is loaded
            Dim rows As HtmlElementCollection
            rows = WebBrowser1.Document.GetElementsByTagName("table")(1).GetElementsByTagName("tr")
    
            For i = 1 To rows.Count - 1
                Dim row As HtmlElement
                row = rows(i)
    
                If row.GetElementsByTagName("td").Count > 1 Then
                    Dim god, lastKilledBy, killedTime As String
                    god = row.GetElementsByTagName("td")(0).InnerText
                    lastKilledBy = row.GetElementsByTagName("td")(1).InnerText
                    killedTime = row.GetElementsByTagName("td")(2).InnerText
    
                    Dim tempData As tableData
    
                    tempData.lastKilledBy = lastKilledBy
                    tempData.time = killedTime
    
                    If names.Keys.Contains(god) Then
    
                        names(god) = tempData
                    Else
                        names.Add(god, tempData)
                    End If
                End If
            Next
            MsgBox("Working Done, Click button3")
            'now names has all the information you need
    
        End Sub
    
        Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            For Each key As String In names.Keys
                RichTextBox1.AppendText(key & ":" & names(key).lastKilledBy & ":" & names(key).time & vbCrLf)
            Next
        End Sub
    End Class

    Thanks

    My BlogMy FacebookYOUR Place to have fun time ! Awesome RPG Action Game
    • Proposed as answer by Omie Wednesday, November 25, 2009 9:05 AM
    • Marked as answer by Martin Xie - MSFT Friday, November 27, 2009 12:13 PM
    Wednesday, November 25, 2009 7:19 AM

  • I've taken data as String, if you're gonna do further work with date, would be convenient if you convert that string into Date. Take a look at Date.ParseExact() method.


    Thanks

    My BlogMy FacebookYOUR Place to have fun time ! Awesome RPG Action Game
    Wednesday, November 25, 2009 7:26 AM
  • Thats perfect for the data. thank you. now do i have to have the webbrowser in my prog or can it do all the text extraction behind the scenes? because what i want to do is to click one button, have it retrieve all the data and then save it back to my database. i think i can manipulate the code to do that.

    thank you again.
    Wednesday, November 25, 2009 7:40 AM

  • You can simple Set Visibility property of that webbrowser to false. but then you need to start work from webrbowser's document completed event. That is to start work after document is loaded. but it gets messy sometimes. use try-catch.

    something like-


    sub document_completed handles webbrowser1.documentcompleted
      workSubroutine()
    end sub

    workSubroutine()
     Try
      'code from button2.click
     Catch
     EndTry
    End sub


    Thanks

    My BlogMy FacebookYOUR Place to have fun time ! Awesome RPG Action Game
    • Proposed as answer by Omie Wednesday, November 25, 2009 9:05 AM
    • Marked as answer by Martin Xie - MSFT Friday, November 27, 2009 12:13 PM
    Wednesday, November 25, 2009 7:48 AM
  • ahhh. gotcha. well u have definitely answered my question and my problem. i thank you so much because now that i read the code i can understand how it works and if i need anything else like this in the future ill know how to handle it. many thanks.
    Wednesday, November 25, 2009 7:52 AM