VBA Webscraping,从脚本标记

时间:2015-04-27 08:17:34

标签: javascript html excel vba web

我一直在构建一个刮刀,我已经设法将我需要的大部分信息写入excel表,一条信息导致我出现问题,因为它是一段HTML,我不熟悉刮擦。

<script type="text/javascript">
    var mapOptions = {
        property: {
            PropertyID: 1234567,
            Address: "Address, Address, Address",
            Price: "€100,000",
            Map: {"Latitude":00.0000000,"Longitude":00.0000000,"Accuracy":2,"IsAutoGeocoded":true,"Polygons":[]},
            MainPhotoUrl: "//photo.jpg",
            PropertySection: 1
        },
        propertySection: "residential",
        baseUrl: "",
        useOpenLayer: false,
        zoom: 15
    };
</script>

我试图从这个脚本中剔除经纬度,任何想法如何?

1 个答案:

答案 0 :(得分:0)

你可以尝试这个,它可能不是最干净的方法,但它应该可以工作,你只需要将它转换为数值供以后使用:

Sub tez()
Dim Src As String
Src = "___________Latitude_:03.0000080,_Longitude_:05.0000070,_"

Dim LatD As String
Dim LonD As String

LatD = GetInfo(Src, "Latitude")
LonD = GetInfo(Src, "Longitude")

MsgBox LatD & Chr(13) & LonD
End Sub

Public Function GetInfo(ByVal Str_D As String, ByVal Info_To_Get As String) As String
Dim AddressInfo As Double
AddressInfo = InStr(1, Str_D, Info_To_Get) + Len(Info_To_Get) + 2

GetInfo = Mid(Str_D, AddressInfo, InStr(AddressInfo, Str_D, ",") - AddressInfo)

End Function