Hi All,
This is my first post on this forum
I've been coding this Sub in VBA in order to do web scrapping. I managed to extract the HTML code from it, that is stored in the string variable readHTML.
readHTML (the string var) looks like:
Note: the name I want to extract is in red (John Smith).
Now I'm trying to extract a certain string (a name) from the readHTML variable, and I don't get why my code isn't working.
According to [A], the only issue is that tempFullNameEnd returns 0.
What is happening?
Thanks in advance,
T.
This is my first post on this forum
I've been coding this Sub in VBA in order to do web scrapping. I managed to extract the HTML code from it, that is stored in the string variable readHTML.
readHTML (the string var) looks like:
Code:
[...] <DIV id=name class=editable-item>
<H1><SPAN class="n fn"><SPAN class=full-name>[COLOR="Red"]John Smith[/COLOR]</SPAN><SPAN></SPAN></SPAN></H1></DIV></DIV>
<DIV id=headline-container data-li-template="headline">
<DIV id=headline class=editable-item> [...]
Now I'm trying to extract a certain string (a name) from the readHTML variable, and I don't get why my code isn't working.
Code:
Dim tempFullNameStart, tempFullNameEnd As Long
Dim FullNameMarkerStart, FullNameMarkerEnd As String
FullNameMarkerStart = "<SPAN class=full-name>"
FullNameMarkerEnd = "</SPAN>"
tempFullNameStart = InStr(1, readHTML, FullNameMarkerStart, 1) + Len(FullNameMarkerStart)
tempFullNameEnd = InStr(tempZoneFullNameStart, readHTML, FullNameMarkerEnd, 1)
Dim tempdifference As Long
tempdifference = tempFullNameEnd - tempFullNameStart
FullName = Mid(readHTML, tempFullNameStart, tempdifference)
' [COLOR="Red"][A][/COLOR] This is just a test to check what values the Sub is returning.
MsgBox ("tempFullNameStart= " & tempFullNameStart & ". tempFullNameEnd = " & tempFullNameEnd & ". Difference = " & tempdifference)
MsgBox ("His name is " & FullName)
According to [A], the only issue is that tempFullNameEnd returns 0.
What is happening?
Thanks in advance,
T.