|
-
Oct 22nd, 2007, 02:20 AM
#1
Thread Starter
New Member
Parsing help.
I am grabbing html from a website, in the source I want to parse out the TOKEN are without the "" around it. I have no idea of how to do this.
Code:
name="org.apache.struts.taglib.html.TOKEN" value="aecc4e108cb6295bb9131ea04b92f2cf">
Where is aecc4e108cb6295bb9131ea04b92f2cf, that is the TOKEN, I need that to be parsed out and to be added to a list or a textbox.
Any help is appreciated.
Thank you,
mikeyy.
-
Oct 22nd, 2007, 02:35 AM
#2
Re: Parsing help.
Are you using webbrowser control? Research on HTML document object model, then do a search here in forums of sample parsing/extraction through HTML DOM.
-
Oct 22nd, 2007, 03:11 AM
#3
Addicted Member
Re: Parsing help.
vb Code:
Dim Parts() As String
'Const T = "name=""org.apache.struts.taglib.html.TOKEN"" value=""aecc4e108cb6295bb9131ea04b92f2cf"">"
'T is the variable with all of the html in
'You should remove the const of it.
Parts() = Split(T, Chr(34))
'Splitting the different parts of the string into an array, by the delimeter of "
'MsgBox Parts(0) & vbNewLine & Parts(1) & vbNewLine & Parts(2) & vbNewLine & Parts(3)
'Part 3 is the token.
List1.AddItem Parts(3)
 Originally Posted by Vanasha
Sorry, i'm slow.
-
Oct 22nd, 2007, 10:58 AM
#4
Re: Parsing help.
If "org.apache.struts.taglib.html.TOKEN" only appears once in the text, use InStr() to find it, then take 32 characters starting from the 45th character after what InStr() returned.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Oct 23rd, 2007, 04:10 PM
#5
Thread Starter
New Member
Re: Parsing help.
I've found my solution for grabbing the TOKEN with:
Code:
StrToken = GetBetween(1, StrPage, _
"org.apache.struts.taglib.html.TOKEN"" value=""", """>", vbTextCompare)
Now I have another problem, I want to be able to parse multiple userID's from a page of online users, the code I want to get between is:
I used:
Code:
Dim StrPage As String
StrPage = Inet1.OpenURL("http://www.stickam.com/whosLive.do?listType=live")
StrToken = GetBetween(1, StrPage, _
"vchat_", "'", vbTextCompare)
lstGen.AddItem (StrToken)
The problem is not the parsing, the problem is it only grabs one userID out of the 100 other users. Do you know a way where it can grab each userID and add each one to a listbox?
(Reply to leinad31: I am using Inet, then just parsing out the source.")
Thank you,
mikeyy.
-
Oct 23rd, 2007, 04:29 PM
#6
Re: Parsing help.
Assuming you have each line separately.. this will separate the 'aecc....'
Text1.text = the string :name="org.apache.st.....
you can change to your string afterwards...
Code:
Dim temp As String
Dim pos As Long
pos = InStr(1, Text1.Text, "value=") 'Get char position for "Value="
If Not pos = 0 Then
temp = Right$(Text1.Text, Len(Text1) - pos - 5)
temp = Left$(temp, Len(temp) - 1) ''Remove > from the End
temp = Replace(temp, Chr(34), "") 'Remove ""
MsgBox temp 'or List1.Add temp
End If
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Oct 23rd, 2007, 04:32 PM
#7
Thread Starter
New Member
Re: Parsing help.
I've fixed the TOKEN problem, please read my above post about the userID.
thank you,
mikeyy.
-
Oct 24th, 2007, 03:46 AM
#8
Addicted Member
Re: Parsing help.
Why would you want to know their userID and token?
 Originally Posted by Vanasha
Sorry, i'm slow.
-
Oct 24th, 2007, 07:45 AM
#9
Thread Starter
New Member
Re: Parsing help.
The token was to add the userID, now I am going to try and parse out online users and save them to a listbox. Before hand I had just made a function to generate the userIDs, but that usually just added inactive accounts.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|