|
回36楼学良大师:
工作表代码:
Public arr
Private Sub Worksheet_Activate()
Dim html, i%, j%, t, t2 As String
With CreateObject("msxml2.xmlhttp")
.Open "get", "http://webmap0.map.bdstatic.com/newmap/static/common/pkg/init-pkg_75a504f.js", False
.send
t = Split(Split(.responsetext, "){var i=""")(1), """")(0)
For i = 0 To UBound(Split(t, ","))
t2 = t2 & Split(t, ",")(i) & ","
Next i
End With
arr = Split(t2, ",")
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count > 1 Then GoTo 100: Exit Sub
If Target.Address <> "$F$1" Then GoTo 100: Exit Sub
[d4] = ""
With Me.TextBox1
.Visible = True
.Top = Target.Offset(1, 0).Top
.Left = Target.Left
.Width = Target.Width
.Height = Target.Height + 10
.Activate
End With
With Me.ListBox1
.Visible = True
.Top = Target.Offset(1, 0).Top
.Left = Target.Left + Target.Width
.Height = Target.Height * 10
.List = arr
End With
Exit Sub
100:
Me.ListBox1.Clear
Me.TextBox1 = ""
Me.ListBox1.Visible = False
Me.TextBox1.Visible = False
End Sub
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
ActiveCell.Value = ListBox1.Value
Me.ListBox1.Clear
Me.TextBox1 = ""
Me.ListBox1.Visible = False
Me.TextBox1.Visible = False
[e4].Select
End Sub
Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Dim i As Integer
Dim Language As Boolean
Dim myStr As String
Me.ListBox1.Clear
With Me.TextBox1
For i = 1 To Len(.Value)
If Asc(Mid$(.Value, i, 1)) > 255 Or Asc(Mid$(.Value, i, 1)) < 0 Then
Language = True
myStr = myStr & Mid$(.Value, i, 1)
Else
myStr = myStr & UCase(Mid$(.Value, i, 1))
End If
Next
End With
For i = 1 To UBound(arr)
If InStr(arr(i), myStr) > 0 Then
Me.ListBox1.AddItem arr(i)
End If
Next
End Sub
模块代码:
Sub 百度地图搜索结果导出文件()
Dim url, html, js
ActiveSheet.UsedRange.Offset(1).ClearContents
br = [{"店名","地址","电话"}]
Range("a1:c1") = br
url = ""
Set html = CreateObject("htmlfile")
Set js = CreateObject("scriptcontrol")
js.Language = "jscript"
For p = 1 To 5
With CreateObject("msxml2.xmlhttp")
url = "http://map.baidu.com/?newmap=1"
url = url & "&reqflag=pcmap"
url = url & "&biz=1"
url = url & "&from=webmap"
url = url & "&qt=s"
url = url & "&from=webmap"
url = url & "&c=" & Split([F1], "|")(1)
url = url & "&pl_data_type=cater"
url = url & "&pl_sub_type=" & [D1]
url = url & "&pl_price_section=0%2C%2B"
url = url & "&pl_sort_type=data_type"
url = url & "&pl_sort_rule=0"
url = url & "&pl_discount2_section=0%2C%2B"
url = url & "&pl_groupon_section=0%2C%2B"
url = url & "&pl_cater_book_pc_section=0%2C%2B"
url = url & "&pl_ticket_book_flag_section=0%2C%2B"
url = url & "&pl_movie_book_section=0%2C%2B"
url = url & "&pl_business_type=cater"
url = url & "&pl_business_id="
url = url & "&pl_activity_gwj_section=0%2C%2B"
url = url & "&wd=" & [D1]
url = url & "&pn=1"
url = url & "&db=0"
url = url & "&wd2="
url = url & "&sug=0"
url = url & "&da_src=pcmappg.poi.page"
url = url & "&on_gel=1"
url = url & "&src=7"
url = url & "&gr=3"
url = url & "&l=12"
url = url & "&addr=0"
url = url & "&nn=" & (p - 1) * 10
url = url & "&tn=B_NORMAL_MAP"
url = url & "&ie=utf-8"
url = url & "&t=1412423900383"
.Open "get", url, False
.send
js.addcode ("suwenkai = " & .responsetext)
If js.Eval("suwenkai.content") = False Then
Exit For
End If
slen = js.Eval("suwenkai.content.length") - 1
For i = 0 To slen
n = n + 1
Cells(n + 1, 1) = js.Eval("suwenkai.content[" & i & "].name")
Cells(n + 1, 2) = js.Eval("suwenkai.content[" & i & "].addr")
Cells(n + 1, 3) = js.Eval("suwenkai.content[" & i & "].tel")
Next
End With
Next
End Sub
|
评分
-
1
查看全部评分
-
|