I am quite new to web scraping and have a minor VBA knowledge. I would like to extract the href value/text from a parsed html code.
The html code:
- <div class="position_and_company">
- <h2><span class="name_highlight_left_middle"> </span><span class="name_highlight_left">
- </span><span class="name_highlight_left_bottom"> </span>
- <span class="name_highlight_middle_bottom"> </span><span class="name_highlight_right"> </span>
- <a href="http://www.profession.hu/allas/mernok-ertekesito-bankonzult-kft-budapest-766812/optimum" target="_blank">
- <strong><span class="highlight">Mérnök</span> <span class="highlight">értékesítő</span></strong>
And here is my VBA code which wants to get the href value:
- 'set the collection for those links which are in the "position_and_company" class
- Set my_data = .Document.getElementsByClassName("position_and_company").getElementsByTagName("a")i = 1
- For Each elem In my_data
- i = i + 1
- 'copy the data to the excel sheet
- ActiveSheet.Cells(i, 4).Value = elem.href
- ActiveSheet.Cells(i, 2).Value = elem.innerText
So basically what I am trying to do is to get the href values (the links actually) only from those classes which are called "position_and_company".
My problem is that the code is not working, each time I run it I get a runtime error: 438 (Object doesn't support this property or method) for the line below:
What am I doing wrong? Why isn't this code working?
Thank you in advance!