|
楼主 |
发表于 2011-5-20 23:31
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
由于东莞地税有验证码的变动,重新做了,代码如下。- Option Explicit
- Sub Test()
- Dim tmp() As String, i As Integer, arr() As String, xmlhttp As Object, N As Long, TMP1() As String, NM As Long, p As Long, k As Integer, Fpdm(1 To 10) As String, Fphm(1 To 10) As String
- Dim Url As String, yzm As String, nyzm As String
-
- N = [a65536].End(xlUp).Row
- NM = Application.Ceiling((N - 1) / 10, 1)
-
- For p = 1 To NM
-
- Cells(2, 3).Value = "正在查询,稍等..."
-
- For k = 1 To 10
- Fpdm(k) = Cells((p - 1) * 10 + k + 1, 1).Value
- Fphm(k) = Cells((p - 1) * 10 + k + 1, 2).Value
- Next k
-
- For k = 1 To 10
- Url = Url & "&fpdm" & k & "=" & Fpdm(k) & "&fphm" & k & "=" & Fphm(k)
- Next k
-
- Erase Fpdm
- Erase Fphm
-
- Url = "http://www.dgds.gov.cn/wssw/fpcjController.do?cmd=fpcjcheck" & Url
-
- Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
- With xmlhttp
- .Open "get", "http://www.dgds.gov.cn/wssw/jsp/yzmForCommonQuery.jsp", False
- .send
- yzm = Split(Split(.responsetext, "checkcode")(2), ".png")(0)
- nyzm = cyzm(yzm)
- End With
- Url = Url & "&yzm=" & nyzm
-
- With xmlhttp
- .Open "get", Url, False
- .send
- tmp() = Split(Replace(Replace(Replace(.responsetext, vbCrLf, ""), "</span>", ""), " ", ""), "<td description=")
- End With
- ReDim arr(UBound(tmp) \ 7, 6)
- For i = 1 To UBound(tmp)
- TMP1() = Split(Split(tmp(i), "</td>")(0), ">")
- arr((i - 1) \ 7, (i - 1) Mod 7) = TMP1(UBound(TMP1))
- Erase TMP1
- Next i
-
- Cells((p - 1) * 10 + 2, 4).Resize(UBound(arr, 1) + 1, UBound(arr, 2) + 1) = arr
-
- Erase tmp
- Erase TMP1
- Erase arr
- Set xmlhttp = Nothing
- Url = ""
-
- Next p
-
- Cells(2, 3).Value = "查询状态栏"
-
- [D:J].Columns.AutoFit
- MsgBox "Ok"
- End Sub
- Function cyzm(yzm As String) As String
- Dim c As Integer, d(1 To 4) As String
- For c = 1 To 4
- If Val(Mid(yzm, c, 1)) - c >= 0 Then
- d(c) = Trim(Str(Val(Mid(yzm, c, 1)) - c))
- Else
- d(c) = Trim(Str(Val(Mid(yzm, c, 1)) - c + 10))
- End If
- Next
- cyzm = Join(d(), "")
- End Function
复制代码
[ 本帖最后由 xmyjk 于 2011-5-20 23:36 编辑 ] |
|