[VB .NET] Question regarding parsing..I'm stuck. =\

Xecurity.

Newbie
Joined
Dec 5, 2012
Messages
2
Reaction score
0
Ok, so to make a long story short I'm making an automator/bot for Mocospace(yes, i know its broken o down but ive gotten excellent results.) Anyways, Ive gotten everything down from comments, messages, and all but I can't seem to get the parsing of the usernames down. The HTML isn't complicated at all, I'm just not too familiar with RegEx and/or VisualBasic.Left,Mid,Right, etc. So could someone please assist me in this problem. Once that program is in beta stage, i'll be more than happy to release a pre-beta as well.


Ok so, heres what I'm trying to do..

Possible parse #1:
HTML:
<strong> <a href="/manofgod78">manofgod78</a> </strong> <div class="asl" style="float: right"> 34 M </div> </div> <div class="asl" style="padding-top: 5px">
**"manofgod78" is what I'm trying to parse and have added to listbox.**

I appreciate all the help, in advance.

-Xecurity.
 
Might not be the best way (because it's not regex) but you can use Getbetween to get one item, or GetBetweenAll to get multiple items and add them to a listbox.

Public Function GetBetween(ByRef strSource As String, ByRef strStart As String, ByRef strEnd As String, Optional ByRef startPos As Integer = 0) As String
Dim iPos As Integer, iEnd As Integer, lenStart As Integer = strStart.Length
Dim strResult As String

strResult = String.Empty
iPos = strSource.IndexOf(strStart, startPos)
iEnd = strSource.IndexOf(strEnd, iPos + lenStart)
If iPos <> -1 AndAlso iEnd <> -1 Then
strResult = strSource.Substring(iPos + lenStart, iEnd - (iPos + lenStart))
End If
Return strResult
End Function

Public Function GBA(ByRef strSource As String, ByRef strStart As String, ByRef strEnd As String, _
ByVal lstAdd As ListBox, Optional ByRef startPos As Integer = 0) As String
Dim iPos As Integer, iEnd As Integer, strResult As String, lenStart As Integer = strStart.Length

Do Until iPos = -1
strResult = String.Empty
iPos = strSource.IndexOf(strStart, startPos)
iEnd = strSource.IndexOf(strEnd, iPos + lenStart)
If iPos <> -1 AndAlso iEnd <> -1 Then
strResult = strSource.Substring(iPos + lenStart, iEnd - (iPos + lenStart))
lstAdd.Items.Add(strResult)
startPos = iPos + lenStart
End If
Loop

GBA = ""
End Function
 
Oh sweet! Thanks a million bro, I had the GetBetween but not the GBA. I appreciate it.
 
did you get it too work ? i could make up a (messy) regex or even split will work. Try and use array's as well ie arraylist , i know it looks cool when the list box fills up with items ( well from my own experience lol), but its sooo much faster and efficient using arrays (and others) not to mention you can multithread items from them, not like list box's
 
Here is a regex that will do it:

Code:
<strong>\s*<a href=\"\/(.+?)\">(.+?)</a>\s*</strong>
 
Back
Top