Vb Gangsta Posted September 14, 2003 Posted September 14, 2003 I am on the last part of my program but am stuck on the one thing. What I need to do is copy a list of names from a variable url. Here is a sample of what the webpage looks like: Click Here to see. The names in yellow need to be copied to a listbox. Could someone plaese tell me in detail how to go about doing this. Thank you Quote Thanks for any Help!!! -Rob
aewarnick Posted September 14, 2003 Posted September 14, 2003 What are you having trouble with, exactly? Adding the names as items in the listbox? Quote C#
Vb Gangsta Posted September 14, 2003 Author Posted September 14, 2003 I am having trouble getting the names from the website Quote Thanks for any Help!!! -Rob
Jay1b Posted September 14, 2003 Posted September 14, 2003 I tried to go to the site, to see how it was made - but its 'having difficulties'. Sorry. Worst comes to worst, search for any piece of code which preceds and follows the names that you want. Long and drawn out - but it would work. Quote
aewarnick Posted September 14, 2003 Posted September 14, 2003 You mean you want to connect to the page and get the names from the page. You know that html pages are just text file don't you? Just open the file with a StreamReader and look for the place where the names are. Now, getting the actual text from the page, I have no idea how to do but once you get it, everything should be easy. Quote C#
Vb Gangsta Posted September 15, 2003 Author Posted September 15, 2003 Yeah but how do i get the webpage into text and then get the information i need. How do I tell the program to copy all the information i need from the specific place? Quote Thanks for any Help!!! -Rob
Vb Gangsta Posted September 15, 2003 Author Posted September 15, 2003 OK , i have been looking at the source code of the webpage. I know it looks complicated but bear with me. This is just a little of the page but its a pattern. All the words in red i need to put into a list. Can some one help me figure out how to do this? Thanks <tr> <td width="13%" bgcolor="#494949" align="center">302</td> <td width="45%" bgcolor="#494949"><a href="profile.php?id=471916">jerkass</a></td> <td width="19%" bgcolor="#494949">32,755</td> <td width="23%" bgcolor="#494949">$4,225,896</td> <td width="23%" bgcolor="#494949">$0</td> </tr> <tr> <td width="13%" align="center">303</td> <td width="45%"><a href="profile.php?id=1005793">Laser28</a></td> <td width="19%">32,686</td> <td width="23%">$0</td> <td width="23%">$31,160,354</td> </tr> <tr> <td width="13%" bgcolor="#494949" align="center">304</td> <td width="45%" bgcolor="#494949"><a href="profile.php?id=869471">Mephew</a></td> <td width="19%" bgcolor="#494949">32,534</td> <td width="23%" bgcolor="#494949">$717,989</td> <td width="23%" bgcolor="#494949">$100,000,000</td> </tr> <tr> <td width="13%" align="center">305</td> <td width="45%"><a href="profile.php?id=823536">Ifyahearme122</a></td> <td width="19%">32,501</td> <td width="23%">$-522,028</td> <td width="23%">$51,774,195</td> Quote Thanks for any Help!!! -Rob
Moderators Robby Posted September 15, 2003 Moderators Posted September 15, 2003 This should get you started...http://www.xtremedotnettalk.com/showthread.php?s=&threadid=42371&highlight=parse Quote Visit...Bassic Software
Vb Gangsta Posted September 15, 2003 Author Posted September 15, 2003 Thank you very much. I used this code. Then i added the variable sData to my list box. As expected it added all of the html to the listbox and on 1 line. Now the Big Question is how do I get the program to get the names, and how do I get it to put each name on a differnt line? Thanks a lot!! Dim sData As String Dim stream As IO.StreamReader Dm wc As New Net.WebClient() stream = New IO.StreamReader(wc.OpenRead("file URL here")) sData = stream.ReadToEnd Quote Thanks for any Help!!! -Rob
aewarnick Posted September 15, 2003 Posted September 15, 2003 You need to use a pattern that is consistant with each name like this: profile.php?id=471916"> Use a loop to iterate through all the characters in the html doc. bool pFound=false; bool stillOk=false; foreach(char c in sData) { switch(c) { case 'p': { pFound=true; break; } case 'r': { if(pFound) stillOk=true; else stillOk=false; break; } } }Although the best way would be to use a regular expression. I have to go to work now. Quote C#
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.