VBA Parsing the webpage for a specific value between tags

dimer

New Member
Joined
Dec 7, 2011
Messages
12
Hi all,

I am trying to extract a specific value from a static webpage.

so far I come up with the following script:
Sub Macro1()
my_url = "http://www.investopedia.com/search/default.aspx?q=rog"
Set my_obj = CreateObject("MSXML2.XMLHTTP")
my_obj.Open "GET", my_url, False
my_obj.send
my_var = my_obj.responseText
MsgBox my_var
Set my_obj = Nothing
End Sub

So my_var returning the whole webpage data. But from all that mess I need to find < div class="exchange">NYSE< </< font>div> and return in this case value NYSE?? How can I do that? please help!!!

 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
This single line of code should do what you want...

Code:
ExchangeName = Split(Split(my_var, "div class=""exchange"">", , vbTextCompare)(1), "<")(0)
where I just made up a variable name to receive the "NYSE" from the expression to the right of the equal sign.
 
Upvote 0
Wow, I really like your idea of using two splits.. how did I not think of that..

Thank you very much,

The case is solved.
 
Upvote 0

Forum statistics

Threads
1,213,513
Messages
6,114,064
Members
448,545
Latest member
kj9

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top