|
Sub 高校选考()
Dim i, j, Arr, odom, S, URL, token1, num, str, endpage, postdata
'--------变手动计算
With Application
.Calculation = xlManual
End With
'--------变手动计算
Set odom = CreateObject("htmlfile")
Set x = CreateObject("MSXML2.xmlhttp")
ReDim Arr(1 To 18850, 1 To 5)
URL = "http://query.bjeea.cn/queryService/rest/plan/134"
postdata = "examId=5550&enrollBatch=&province=&schoolName=&examId2=5550&enrollBatch2=&specialtyName=&kskmgx=0&optionType=1&queryType=2"
With x
.Open "POST", URL, False
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.send postdata
str = .responseText
End With
token1 = Split(Split(str, "token=""")(1), """")(0)
endpage = CInt(Split(Split(Split(str, "searchGotoPage")(6), "(")(1), ")")(0))
num = 328
For i = 1 To endpage
postdata = "pageFlag=true&token=" & token1 & "&pageSize=50&pageNo=" & i & "&" & postdata
With x
.Open "POST", URL, False
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.send postdata
odom.body.innerhtml = .responseText
' Open ThisWorkbook.Path & Path & "\1.txt" For Append As #1
' Print #1, str
' Close #1
End With
If i = endpage Then num = 377
For j = 34 To num Step 5
m = m + 1
Arr(m, 1) = "=row()-1"
For k = 1 To 5
Arr(m, k) = odom.getElementsByTagName("td")(j + k - 1).innertext
Next k
Next j
Next i
Set x = Nothing
Set odm = Nothing
Sheet4.UsedRange.Offset(1).ClearContents
Sheet4.Range("A2").Resize(UBound(Arr), UBound(Arr, 2)) = Arr
'--------变自动计算
With Application
.Calculation = xlAutomatic
End With
'--------变自动计算
End Sub
|
|