|
发表于 2014-3-24 23:46:07
|
显示全部楼层
1,创建一个按钮。
2,添加VB代码。
不懂的加QQ群 54894887 找我【牛牛】
Function SplitCN(Target, attr, topnum)
Dim StrHTML$, lStart&, lEnd&, dua$, Ign$
URL = "http://www.xunsearch.com/scws/demo/v48.php"
'sendstr = "mydata=" & Target & "&stats=yes&limit=" & topnum & "&xattr=" & attr
'mydata,stats,limit,xattr,表单控件名
sendstr = "mydata=" & Target & "&limit=" & topnum & "&xattr=" & attr
With CreateObject("Msxml2.XMLHTTP")
.Open "POST", URL, False
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.send sendstr
StrHTML = .responseText
End With
'StrHTML 获取到的网页内容,然后处理
lStart = InStrRev(StrHTML, "<textarea")
lEnd = InStrRev(StrHTML, "</textarea>")
StrHTML = Mid(StrHTML, lStart, lEnd - lStart - 2)
StrHTML = Right(StrHTML, Len(StrHTML) - InStr(StrHTML, ">") - 1)
SplitCN = Trim(StrHTML)
End Function
Private Sub CommandButton1_Click()
Dim j
Dim st As String
For j = 7 To 14
Sheet1.Cells(j, 5) = ""
Next
attr = "n,v,a,d,r,m,t,i,ad"
st = Sheet1.Cells(7, 2) '这里是Sheet1表的7行B列
topnum = 10
st = Replace(st, "&", "")
For j = 7 To 14
st = Sheet1.Cells(j, 2)
Sheet1.Cells(j, 5) = SplitCN(st, attr, topnum)
Next
MsgBox ("恭喜!已完成")
ExitHandler:
End Sub |
|