|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
转个码就可以啦
Public Sub cx()
Dim strURL As String
Dim strData As String
Dim xmlHttp As Object
Dim sHtml$
Set xmlHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
With xmlHttp
.Open "POST", "http://www.ynzs.cn/2017gkcf/check.php?action=query", False
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.setRequestHeader "Referer", "http://www.ynzs.cn/2017gkcf/web.html"
.setRequestHeader "Cookie", "CNZZDATA5457195=cnzz_eid%3D24226550-1530624128-%26ntime%3D1530714216; PHPSESSID=fpi8fa0srsmp2ecqaarlq6ngs7; UM_distinctid=16460561fb3d-01d889be24bdcf4-1d317173-1fa400-16460561fb474"
.send "user=252651640&pass=888888"
strData = Replace(Replace(Replace(Split(.responseText, "url")(1), "}", ""), """:", ""), """", "")
strData = Replace(strData, "\", "")
.Open "GET", strData, False '
.send
sHtml = Replace(ByteToStr(.responsebody, "UTF-8"), " ", "")
End With
Dim js As Object
Set js = CreateObject("MSScriptControl.ScriptControl")
js.Language = "JavaScript"
js.AddObject "rg", [A1]: js.AddObject "r", [b2]
js.AddCode "function ka(s){ return s.match(/>(.*?)(?=<\/td>)/gm);};"
js.AddObject "y", js.CodeObject.ka(sHtml)
Stop
js.eval ("rg(1,1)='姓名',rg(1,2)='科目',rg(1,3)='科目成绩',rg(1,4)='百分比等级',rg(2,1)=y[6].replace(/>/,'');")
js.eval ("k=1,l=y.length;for(i=7;i<l;i =i +3){ for (j=0;j<3;j++){rg(k+1,j+2)=y[i+j].replace(/>/,'').replace(/;/,'');};k++;};")
End Sub
Function ByteToStr(arrByte, strCharset As String) As String
With CreateObject("Adodb.Stream")
.Type = 1
.Open
.write arrByte
.Position = 0
.Type = 2
.Charset = strCharset
ByteToStr = .Readtext
.Close
End With
End Function
|
评分
-
1
查看全部评分
-
|