Results 1 to 6 of 6

Thread: [RESOLVED] Multiple HTML Parsing + Loop

  1. #1

    Thread Starter
    Junior Member simonwinsor's Avatar
    Join Date
    Apr 2008
    Location
    USA
    Posts
    22

    Resolved [RESOLVED] Multiple HTML Parsing + Loop

    Have been Trying to Parse The Data from a website Source to Database but all i get is the first value and i cant loop to the next ..

    what i wana extract from the source is title='Computer Hardware'
    The link = http://domainhidden.com/files/dl.php?id=/zvovk6c6zn66
    And the Department "(Technical)"

    HTML Code:
    <div id='sys112'>
    
    <img src='image/button.gif' class='sysipx'><a href='http://domainhidden.com/files/dl.php?id=zvovk6c6zn66' target='_blank' class='sam_dza' title='Computer Hardware'>Computer Hardware</a> <span style='color:#819643; font:normal 7pt trebuchet MS;'>(Technical)</span><br>
    <img src='image/button.gif' class='sysipx'><a href='http://domainhidden.com/files/dl.php?id=uumtd0ah3jxs' target='_blank' class='sam_dza' title='Active Dirictory'>Active Dirictory</a> <span style='color:#819643; font:normal 7pt trebuchet MS;'>(Technical)</span><br>
    <img src='image/button.gif' class='sysipx'><a href='http://domainhidden.com/files/dl.php?id=x753uncesk7e' target='_blank' class='sam_dza' title='New Manager'>New Manager</a> <span style='color:#819643; font:normal 7pt trebuchet MS;'>(Human Resource)</span><br>
    <img src='image/button.gif' class='sysipx'><a href='http://domainhidden.com/files/dl.php?id=ognaj0pab4gx' target='_blank' class='sam_dza' title='Desk Shift'>Desk Shift </a> <span style='color:#819643; font:normal 7pt trebuchet MS;'>(Management)</span><br>
    <img src='image/button.gif' class='sysipx'><a href='http://domainhidden.com/files/dl.php?id=3gya7kue91db' target='_blank' class='sam_dza' title='Annual Function'>Annual Function</a> <span style='color:#819643; font:normal 7pt trebuchet MS;'>(Managemanet)</span>
    
    </div>
    Simon

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Multiple HTML Parsing + Loop

    i don't understand what your question has to do with the html source you have posted

    if you want help to parse a particular page, better to post the source html for that page
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Junior Member simonwinsor's Avatar
    Join Date
    Apr 2008
    Location
    USA
    Posts
    22

    Re: Multiple HTML Parsing + Loop

    Hey westconn1

    The HTML Codes that i have Mention is the Source code after Cleanup of All Unwanted HTML Codes.



    Let me connect you with some Codes

    Code:
    'HTML - is the Richtextbox
    
    Dim lonPos As Long, lonEnd As Long
    Dim strStart As String, strEnd As String
    Dim strinfo1 As String
    
    
    strStart = "a href='" 
    strEnd = "' target="
    
    
    lonPos = InStr(1, HTML, strStart, vbTextCompare)
    
    If lonPos > 0 Then
        
        lonPos = lonPos + Len(strStart)
            
        lonEnd = InStr(lonPos, HTML, strEnd, vbTextCompare)
        
        If lonEnd > 0 Then
            
            strinfo1 = Mid$(HTML, lonPos, lonEnd - lonPos)
            
            'Done!
    
            Text1.Text = strinfo1 ' This will show the URL 
    
        End If
    End If
    Text2 = Computer Hardware
    Text1 = http://domainhidden.com/files/dl.php?id=zvovk6c6zn66
    Text3 = Technical

    After getting the Info and Updating to the Database i wana Parse to next available information from the Source Codes. Basically Looping till i reach the Last of the information available.



    Simon

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Multiple HTML Parsing + Loop

    so next you want??
    text1 = http://domainhidden.com/files/dl.php?id=uumtd0ah3jxs
    text2 = active directory
    text3 = technical
    vb Code:
    1. do
    2. lonPos = InStr(lonpos +  1, HTML, strStart, vbTextCompare)
    3. if lonpos = 0 then exit do
    4. If lonPos > 0 Then
    5.     lonPos = lonPos + Len(strStart)
    6.     lonEnd = InStr(lonPos, HTML, strEnd, vbTextCompare)
    7.     If lonEnd > 0 Then
    8.         strinfo1 = Mid$(HTML, lonPos, lonEnd - lonPos)
    9.         'Done!
    10.         Text1.Text = strinfo1 ' This will show the URL
    11.         msgbox text1
    12.     End If
    13. End If
    14. loop
    this should put each url into the textbox in turn, but without break (not visible to user)
    if instead, you want a button to continue, to get the next url, declare lonpos as static, rather than dim, and remove do /loop
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    Junior Member simonwinsor's Avatar
    Join Date
    Apr 2008
    Location
    USA
    Posts
    22

    Re: Multiple HTML Parsing + Loop

    Hey VBuddy westconn1

    First of all Sorry for my late reply, was caught up in some other work.
    Thanks for Correcting the mention codes and it works just perfect.
    but thats just LOOP, My Confusion is still a Confusion.

    I cant get Multiple Parsing with the Codes that i have mention.

    Regards

    Simon

  6. #6

    Thread Starter
    Junior Member simonwinsor's Avatar
    Join Date
    Apr 2008
    Location
    USA
    Posts
    22

    Re: Multiple HTML Parsing + Loop

    Could not find a other way round so just did this ..

    Instead of creating a String

    strStart = "a href='"
    strEnd = "' target="

    i just replaced the strStart and strEnd with the given information

    after the "msgbox text1" and End IF i looped another search code.

    Tried making it a bit slow by adding sleep function it it just did a perfect job for me.

    Thank you westconn1 for your time and Support

    If anyone needs help feel free to Drop me a PM.

Tags for this Thread

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