[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
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
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
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:
do
lonPos = InStr(lonpos + 1, HTML, strStart, vbTextCompare)
if lonpos = 0 then exit do
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
msgbox text1
End If
End If
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
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
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.