Home > Software engineering >  Vba climb express logistics information in 100 and kuaidihelp, a great god, please help me to look a
Vba climb express logistics information in 100 and kuaidihelp, a great god, please help me to look a

Time:11-23

I use vba to climb express information, but always prompt "results" cannot be found, check a lot of information online, that IP is limited,
For the crawler program, I have some questions, please god help me some directions, or modify the code directly, thank you very much!
1. Climb express 100, a parameter is a temp, this parameter is useless, how to solve the problem of temp?
2. IP is limited, how to use a proxy IP, how to write in the vba program?
3. After using a proxy IP, cookies and the user-agent how to deal with?

Climb kuaidi100 code is as follows:

Sub kd100 ()
Application. EnableEvents=True
Application. ScreenUpdating=False
Dim XMLHTTP As Object, str1 As String, str2 As String
Dim I %, j %
Range (" d1: e70 "). ClearContents
Set XMLHTTP=CreateObject (" WinHttp WinHttpRequest. 5.1 ") 'MSXML2. XMLHTTP WinHttp. WinHttpRequest.
5.1With XMLHTTP
If Cells (2, 2) & lt;> "" Then
. Open the "post", "http://www.kuaidi100.com/autonumber/autoComNum? Text="& amp; Trim (Cells (2, 2). The Value)
. Send a post request, the purpose is to obtain the express company name
Str1=Split (Split (responseText, "comCode" : "" "") (2), "" "") (0)
The Debug. Print str1
. Open the "get", "http://www.kuaidi100.com/query? Type="& amp; Str1 & amp; "& amp; Postid="& amp; Trim (Cells (2, 2). The Value) & amp; "& amp; Temp="& amp; Rnd () & amp; "Phone="
Option (6)=False
. SetRequestHeader "Accept", "application/json, text/javascript, */*; Q=0.01 "
. SetRequestHeader "Accept - Language," "useful - CN, useful; Q=0.8 "
. SetRequestHeader "Connection", "keep alive -
". SetRequestHeader "Cookie", "csrftoken=px575xwqdFtCFzOOrLlIbgcfkqB4646zHZpXPPWGOV4; __guid=112420610.3231980096521463300.1605887476529.404; TOKEN=m5g - GpdoICyx5_4SH5MOg6HlV - i6LjrGFcjoE1eCR0; USER_NAME=% % % % E6 B2 B3 E5 E7 8 d % 97% % % % 9 c % 81% E4 BA 8 E5%94% % d % 81% E9 E5 % % 93% 83% 95% 86% E6 B8 B4 E8 % % % % 9 E5 E9 c % 89% % 99% 90% % 85% 8 E5 AC % % % B8 f; IS_LOGGED=YES; Monitor_count=5; WWWID=WWWC35F4AB686DE10806682D6B6AFBDEF1A; LoginId=386005580; LoginType=POLL; LoginName=hennan_wushiling; Nickname=hennan_wushiling; LoginEmail=null; LoginMobile=null; LoginExt=null; Auth=32; LoginSession=1; Hm_lvt_22ea01af58ba2be0fec7c11b25e88e6c=1605887478160969 167160974 529; Hm_lpvt_22ea01af58ba2be0fec7c11b25e88e6c=1605974529
". SetRequestHeader "Host", "www.kuaidi100.com"
. SetRequestHeader "Referer", "https://www.kuaidi100.com/"
The user-agent. SetRequestHeader ", "" Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36 "
. SetRequestHeader "X - Requested - With", "the XMLHttpRequest
". Send
Logistics data obtained str2.=the responseText '
The Debug. Print str2
'MsgBox str2
End the If
End With
The Set Ms=CreateObject (" MSScriptControl. ScriptControl) 'with the extracted data processing, but the 64 office does not support
Ms. Language="javascript"
Ms. AddCode "a=" & amp; Str2
'MsgBox Ms. Eval (" a.com ")
For j=0 To Ms eval (" a. d. ata. Length ") - 1
Cells (j + 5, 4)=Ms. Eval (" a. d. ata [] "& amp; j & amp;" the time ")
Cells (j + 5, 5)=Ms. Eval (" a. d. ata [] "& amp; j & amp;". The context ")
'Cells (j + 5, 6)=Ms. Eval (" a. d. ata [" & amp; j & amp; "]. Ftime ")' ftime is similar to the time, as well as basic
Next j
Application. ScreenUpdating=True
Application. EnableEvents=True
End Sub


Climb kuaidihelp code is as follows:
Sub Kuaidihelp ()
Dim strText As String, the URL As a String, KdNum As String
Dim I %, Mh As Object, Arr (1 To 99, 1 To 2)
Range (" q2: r100 "). ClearContents: [p2, p3] early processing
="" 'KdNum="9863588744188"
URL="http://m.kuaidihelp.com/express/queryResult"
With CreateObject (" WinHttp WinHttpRequest. 5.1 ")
'. Open the "get", URL, False 'POST, get according to the need to change
Option (6)=False
. SetRequestHeader "Accept", "*/*
". SetRequestHeader "Accept - Language," "useful - CN, useful; Q=0.9 "
. SetRequestHeader "Connection", "keep alive -
"The content-type. SetRequestHeader ", "" application/x - WWW - form - urlencoded; Charset=utf-8 "
. SetRequestHeader "X - Requested - With", "XMLHttpRequest" 'this must add
. SetRequestHeader "Referer", "https://m.kuaidihelp.com/express/queryResult? The word="& amp; Trim (KdNum) 'this can omit
. SetRequestHeader "Cookie", "__guid=186342133.2521275814532956700.1605883142010.0737; UM_distinctid=175 fa400 b4502 e61820a0422 bea918f4178 0-376-1-175 e61820a1455; CNZZDATA30097644=cnzz_eid % 3 d397802876-1605881974 - % 26 ntime % 3 d1605881974; CNZZDATA1260433975 %=1176996879-1605881344-7 c1605881344; CNZZDATA1278216271=1470525690-1605878972-https%253A%252F%252Fm.kuaidihelp.com % 252 f % 7 c1605960799; Saltcode=xDCvG4VQwEqKYiGyBxKugA % 3 d % 3 d; Rand=vb7eqjOzXVHZQNG1bz0qLQ % 3 d % 3 d; Monitor_count=29 "
. SetRequestHeader "Host", "m.kuaidihelp.com"
. SetRequestHeader "Origin", "https://m.kuaidihelp.com"
The user-agent. SetRequestHeader ", "" Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36 "
"Send waybill=" & amp; Trim (KdNum)
The Debug. Print. The responseText
StrText=TestRegUni (. The responseText) 'translated into normal text
, "strText=Replace (strText & lt; Br \/& gt;" , ""), 'the time and date in the middle of the & lt; Br \/& gt; Replace the blank space
End With
'# # # # # # # # # # # # # # # # # # # # # # to deal with data and written to the cell # # # # # # # # # # # # # # # # # # # # # # # # # # #
With CreateObject (" vbscript. Regexp ") 'data were extracted With regular
The Global=True
. The Pattern="date" ":" "(. +?) "" "info ", "" :" "(. +?) ""}"
The Set of Mh=. The Execute (strText)
If Mh. Count=0 Then the Debug. Print "this Courier number does not identify" : the Exit Sub
For I=1 To Mh. Count
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • VBA
  • Related