shahin
Active Member
I've written a macro to pull some information from a webpage. When i run the macro, it populates a result which is br/newline separated string. I would like to get the last portion of that string. Currently what I'm doing is able to fetch me the last value which is phone number. However, i would like to avoid this hardcoding index "(5)" to get the value. If i knew how to count things in the reverse way then I could do it myself because the value i'm after is exactly located in the last position. However, any help on is would be highly appreciated.
This is what I tried with:
The result it produces:
If you run the macro after uncommenting the line then you will find that my script can parse only the phone number. I just wish to do the same without using hardcoding index like what i did. Because, if the string contains more information then the position of that phone number could be 7, 8, 9 whatever and my script will fail to scrape that. But if i continue with the last index without hardcoding then i will always get the accurate result i'm after.
This is what I tried with:
Code:
Sub Data_scraper()
Dim IE As New InternetExplorer
Dim ieDoc As HTMLDocument
With IE
.Visible = False
.navigate "http://www.retailbusinesstechnologyexpo.com/exhibitor-profile/citizen-systems-europe"
Do Until .readyState = 4: DoEvents: Loop
Set ieDoc = .document
MsgBox ieDoc.getElementsByClassName("editorLabel")(0).innerText
' MsgBox Split(ieDoc.getElementsByClassName("editorLabel")(0).innerText, vbNewLine)(5)
End With
IE.Quit
End Sub
The result it produces:
Code:
"Citizen Systems Europe
Elizabeth House
56-60 London Road
Staines-Upon-Thames
TW18 4HF
Tel. 0208 893 1900"
If you run the macro after uncommenting the line then you will find that my script can parse only the phone number. I just wish to do the same without using hardcoding index like what i did. Because, if the string contains more information then the position of that phone number could be 7, 8, 9 whatever and my script will fail to scrape that. But if i continue with the last index without hardcoding then i will always get the accurate result i'm after.