|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Public Function winHttpGetResponse(postURL As String, PostData As String, Method As String, setCookies As String, setReferer As String) As String
If Len(Trim(setCookies)) = 0 Then setCookies = "a:x," '//cookie为空则随便弄个cookie,不然报错
Set WinHttp = CreateObject("WinHttp.WinHttpRequest.5.1") '创建WinHttp.WinHttpRequest
'MsgBox "到 这里"
WinHttp.Open Method, postURL, True '同步接收数据
WinHttp.Option(WinHttpRequestOption_SslErrorIgnoreFlags) = &H3300 '非常重要(忽略错误)
'其它请求头设置
WinHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
WinHttp.setRequestHeader "Referer", setReferer '来路
WinHttp.setRequestHeader "Cookie", setCookies
WinHttp.setRequestHeader "Content-Length", Len(PostData)
WinHttp.Option(4) = 13056 '忽略错误标志
WinHttp.Option(6) = True '为 True 时,当请求页面重定向跳转时自动跳转,False 不自动跳转,截取服务端返回的302状态。
WinHttp.Send PostData '' 开始发送
WinHttp.WaitForResponse '等待请求
'MsgBox WinHttp.Status '请求状态
'得到返回文本(或者是其它)
strText = WinHttp.getAllResponseHeaders
Debug.Print strText
winHttpGetResponse = WinHttp.ResponseText
' Debug.Print winHttpGetResponse
End Function
Dim URL As String '参数:URL,post或get网址
Dim poDa As String '参数:poDa,post内容
Dim Mth As String '参数:Mth,方法,为"POST"或"GET"
Dim cooki As String '参数:cooki,post或get带上的cookie
Dim strweb As String '参数:strweb,post或get带上的cookie
Dim setReferer As String '参数:setReferer,来路
URL = "file:///C:\Users\ADMINI~1\AppData\Local\Temp\%W@GJ$ACOF(TYDYECOKVDYB.pnghttp://bbss.shangdu.com/Login/checklogin.jsp"
poDa = "txtNAME=" & Text1 & "&txtPassword=" & Text2 & "&randomcode=" & Text3 & "&action=newlogin&loginby=0&logintype=0"
'Debug.Print poDa
Mth = "POST"
setReferer = "file:///C:\Users\ADMINI~1\AppData\Local\Temp\%W@GJ$ACOF(TYDYECOKVDYB.pnghttp://bbss.shangdu.com"
调用函数
Call winHttpGetResponse(URL, poDa, Mth, cooki, setReferer)
为什么登陆不了呢???
搞了一个下午都没有搞明白, 请各位大侠指点一下
用户名为:seo123www
密码:qazwsx123
|
|