Here's an example, though I'm not sure it's good one.
Sub GetMPData()
' http://findyourmp.parliament.uk/api/search?q=PE24+4AJ&f=csv
Dim xml As Object
Dim varData
Dim rng As Range
Set xml = CreateObject("MSXML2.XMLHTTP")
Set rng = Range("A2")
While rng.Value <> ""
xml.Open "GET", "http://findyourmp.parliament.uk/api/search?q=" & Replace(rng.Value, " ", "+") & "&f=csv", False
xml.send
varData = Split(Replace(Split(xml.responseText, Chr(10))(1), Chr(34), ""), ",")
rng.Offset(, 1).Value = varData(0)
rng.Offset(, 2).Value = varData(1)
Set rng = rng.Offset(1)
Wend
End Sub
Two rows are returned the first is the headers and the 2nd the actual data.
For example:
constituency_name,member_name,member_party,member_biography_url,member_website, uri
"Boston and Skegness","Mark Simmonds","Conservative","http://www.parliament.uk/biographies/commons/mark-simmonds/25302","http://www.marksimmonds.org/","http://findyourmp.parliament.uk/constituencies/boston-and-skegness.csv"
We split those 2 rows and return the second row, which we then split to get the data.
Bookmarks