Results 1 to 9 of 9

Thread: Parsing help.

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2007
    Posts
    15

    Question 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.

  2. #2
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    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.

  3. #3
    Addicted Member Vanasha's Avatar
    Join Date
    Jun 2007
    Location
    In a bin.>_>
    Posts
    152

    Re: Parsing help.

    vb Code:
    1. Dim Parts() As String
    2. 'Const T = "name=""org.apache.struts.taglib.html.TOKEN"" value=""aecc4e108cb6295bb9131ea04b92f2cf"">"
    3. 'T is the variable with all of the html in
    4. 'You should remove the const of it.
    5. Parts() = Split(T, Chr(34))
    6. 'Splitting the different parts of the string into an array, by the delimeter of "
    7. 'MsgBox Parts(0) & vbNewLine & Parts(1) & vbNewLine & Parts(2) & vbNewLine & Parts(3)
    8. 'Part 3 is the token.
    9. List1.AddItem Parts(3)
    Quote Originally Posted by Vanasha
    Sorry, i'm slow.


  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    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

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2007
    Posts
    15

    Question 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:

    Code:
    _vchat_174375447'
    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.

  6. #6
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    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.



  7. #7

    Thread Starter
    New Member
    Join Date
    Oct 2007
    Posts
    15

    Exclamation Re: Parsing help.

    I've fixed the TOKEN problem, please read my above post about the userID.

    thank you,
    mikeyy.

  8. #8
    Addicted Member Vanasha's Avatar
    Join Date
    Jun 2007
    Location
    In a bin.>_>
    Posts
    152

    Re: Parsing help.

    Why would you want to know their userID and token?
    Quote Originally Posted by Vanasha
    Sorry, i'm slow.


  9. #9

    Thread Starter
    New Member
    Join Date
    Oct 2007
    Posts
    15

    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
  •  



Click Here to Expand Forum to Full Width