|
楼主 |
发表于 2020-8-30 23:26
|
显示全部楼层
Public Sub 安徽2020查询()
'该验证码为文本格式,不是图片,比较好处理
'Cells(rowi, 1),Cells(rowi, 2)分别对应考生号,身份证号
Dim strURL As String
Dim strData As String
Dim XmlHttp As Object
Dim a() As Byte
'Set XmlHttp = CreateObject("MSXML2.XMLHTTP")
Set XmlHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
'strURL = "http://cx.ahzsks.cn/pugao/pgcj2018_in.php"
Set oDoc = CreateObject("htmlfile")
'With CreateObject("WinHttp.WinHttpRequest.5.1")
arr = Range("D2:O61")
'MsgBox arr(1, 2)
With XmlHttp
For rowi = 2 To 2
.Open "GET", "http://cx.ahzsks.cn/pugao/pgcj2020_in.php", False
.send
strText = .getAllResponseHeaders
cookieText = Split(Split(strText, "=")(3), ";")(0)
yzm = Split(Split(Split(.responseText, "yzm")(2), ">")(1), "<")(0)
'Debug.Print yzm
.Open "POST", "http://cx.ahzsks.cn/pugao/pgcj2020_out.php", False
.setRequestHeader "Host", "cx.ahzsks.cn"
.setRequestHeader "Connection", "keep-alive"
.setRequestHeader "Content-Length", "73"
.setRequestHeader "Cache-Control", "max-age=0"
.setRequestHeader "Upgrade-Insecure-Requests", "1"
.setRequestHeader "Origin", "http://cx.ahzsks.cn"
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36 Edg/85.0.564.41"
.setRequestHeader "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
.setRequestHeader "Referer", "http://cx.ahzsks.cn/pugao/pgcj2020_in.php"
.setRequestHeader "Accept-Encoding", "gzip, deflate"
.setRequestHeader "Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6"
.setRequestHeader "Cookie", "PHPSESSID=" & cookieText
txt = Cells(rowi, 2)
a = StrConv(txt, vbFromUnicode, &H804)
For i = 0 To UBound(a)
Url = Url & "%" & Right("0" & Hex(a(i)), 2)
Next
xm = Url
.send "sfzh=" & Cells(rowi, 1) & "&xm=" & xm & "&ksh=" & Cells(rowi, 3) & "&yzm=" & yzm
'.send "sfzh=340503200210040619&xm=%CD%F5%D3%EE%BA%BD&ksh=20340501110240&yzm=" & yzm
strText = .responseText
oDoc.body.innerHTML = Replace(StrConv(.responseBody, vbUnicode), " ", "")
Set tr = oDoc.all.tags("Table")(0).Rows
arr(rowi - 1, 1) = tr(1).Cells(1).innerText
arr(rowi - 1, 2) = tr(1).Cells(3).innerText
arr(rowi - 1, 3) = tr(3).Cells(1).innerText
arr(rowi - 1, 4) = tr(3).Cells(2).innerText
arr(rowi - 1, 5) = tr(4).Cells(1).innerText
arr(rowi - 1, 6) = tr(4).Cells(2).innerText
arr(rowi - 1, 7) = tr(5).Cells(1).innerText
arr(rowi - 1, 8) = tr(5).Cells(2).innerText
arr(rowi - 1, 9) = tr(6).Cells(1).innerText
arr(rowi - 1, 10) = tr(6).Cells(2).innerText
arr(rowi - 1, 11) = tr(7).Cells(1).innerText
arr(rowi - 1, 12) = tr(8).Cells(1).innerText
Next
Range("D2:O61") = arr
End With
End Sub
|
评分
-
1
查看全部评分
-
|