В Великобритании вы можете получить полный адрес с любого почтового индекса, используя 192.com.
У них есть полностью бесплатная база данных, доступная на 192.com
Я не работаю для них или их рекламодателей, но использовал этот сайт для многих приложений ввода данных.
Отформатируйте URL из искомого почтового индекса. т.е.
'a1 1aa' будет http://www.192.com/places/a/a1-1/a1-1aa
После этого будут перечислены все адреса в почтовом индексе.
Вот класс, который я написал, надеюсь, он вам поможет:
Imports System.Net
Imports System.IO
Public Class PCLookup
Property Addresses As List(Of Address)
Public Sub New(Postcode As String)
GetAddresses(CreatDoc(Postcode))
End Sub
Private Function CreatDoc(PostCode As String) As mshtml.HTMLDocument
Dim URL As String = FormatPostcode(PostCode)
If URL = "" Then Return New mshtml.HTMLDocument
Dim request As HttpWebRequest = WebRequest.Create(URL)
Dim response As HttpWebResponse = request.GetResponse()
Dim reader As StreamReader = New StreamReader(response.GetResponseStream())
Dim doc As New mshtml.HTMLDocument
Dim objDoc As mshtml.IHTMLDocument2 = doc
Dim param As Object() = {reader.ReadToEnd()}
objDoc.write(param)
response.Close()
reader.Close()
Return objDoc
End Function
Private Function FormatPostcode(Postcode As String) As String
Dim FullURL As String = "http://www.192.com/places/"
Do Until Postcode.Contains(" ") = False
Postcode = Replace(Postcode, " ", "")
Loop
If Len(Postcode) > 7 Or Len(Postcode) < 5 Then
Return ""
End If
If Len(Postcode) = 5 Then
FullURL &= Mid(Postcode, 1, 1) & "/"
FullURL &= Mid(Postcode, 1, 2) & "-" & Mid(Postcode, 3, 1) & "/"
FullURL &= Mid(Postcode, 1, 2) & "-" & Mid(Postcode, 3) & "/"
End If
If Len(Postcode) = 6 Then
If IsNumeric(Mid(Postcode, 2, 1)) Then
FullURL &= Mid(Postcode, 1, 1) & "/"
FullURL &= Mid(Postcode, 1, 3) & "-" & Mid(Postcode, 4, 1) & "/"
FullURL &= Mid(Postcode, 1, 3) & "-" & Mid(Postcode, 4) & "/"
Else
FullURL &= Mid(Postcode, 1, 2) & "/"
FullURL &= Mid(Postcode, 1, 3) & "-" & Mid(Postcode, 4, 1) & "/"
FullURL &= Mid(Postcode, 1, 3) & "-" & Mid(Postcode, 4) & "/"
End If
End If
If Len(Postcode) = 7 Then
FullURL &= Mid(Postcode, 1, 2) & "/"
FullURL &= Mid(Postcode, 1, 4) & "-" & Mid(Postcode, 5, 1) & "/"
FullURL &= Mid(Postcode, 1, 4) & "-" & Mid(Postcode, 5) & "/"
End If
Return FullURL
End Function
Private Sub GetAddresses(ObjDoc As mshtml.HTMLDocument)
Dim Obj As mshtml.IHTMLElementCollection = ObjDoc.getElementsByTagName("td")
Addresses = New List(Of Address)
For Each TD As mshtml.HTMLTableCell In Obj
If TD.className = "address" Then
Dim FullAddress As String = TD.innerText
Addresses.Add(New Address(FullAddress))
End If
Next
End Sub
End Class
Public Class Address
Property Line1 As String
Property Line2 As String
Property Line3 As String
Property Line4 As String
Property Postcode As String
Public Sub New(FullAddress As String)
Dim Obj As Object = Split(FullAddress, ", ")
Select Case UBound(Obj)
Case 4
Line1 = Obj(0) & " " & Obj(1)
Line2 = ""
Line3 = Obj(2)
Line4 = Obj(3)
Postcode = Obj(4)
Case 5
Line1 = Obj(0) & " " & Obj(1)
Line2 = Obj(2)
Line3 = Obj(3)
Line4 = Obj(4)
Postcode = Obj(5)
Case 6
Line1 = Obj(0) & " " & Obj(1)
Line2 = Obj(2) & " " & Obj(3)
Line3 = Obj(4)
Line4 = Obj(5)
Postcode = Obj(6)
End Select
End Sub
End Class
Извините, если код немного запутанный, программист-самоучка!