用xmlhttp登錄7k7k,并用動態WebBrowser驗證登錄結果,直接上代碼:
Dim web1 As Object
Private Sub Form_Load()
Set web1 = Me.Controls.Add("SHELL.EXPLORER.2", "web1", Me)
web1.Visible = True
web1.Move 0, 0, 1020, 744
web1.object.Silent = True
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
xmlhttp.open "POST", "http://zc.7k7k.com/post_login", False
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.setRequestHeader "Connection", "Keep-Alive"
xmlhttp.send ("username=tst7k01&password=tst7k01")
web1.object.Navigate "http://www.7k7k.com", 0
Set xmlhttp = Nothing
End Sub
原始碼檔案可下載圖片改名.rar獲得:
uj5u.com熱心網友回復:
借寶地請教一下“用XMLHTTP POST方法購買一個東西”
我在IE中抓取的 POST Data

抓取的 Stream:
POST /transfer/buyLoanTransfer.action HTTP/1.1
Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/xaml+xml, application/x-ms-xbap, application/x-ms-application, */*
Referer: http://www.we.com/transfer/loanTransferDetail.action?transferId=5406298
Accept-Language: zh-cn
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; EmbeddedWB 14.52 from: http://www.bsalsa.com/ EmbeddedWB 14.52; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727)
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Host: www.we.com
Content-Length: 106
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: Hm_lvt_16f9bb97b83369e62ee1386631124bb1=1450249491,1450250637,1450250754; Hm_lpvt_16f9bb97b83369e62ee1386631124bb1=1450251282; JSESSIONID=9EA10E3E91720A09B3546E7908F968CE92CF6F1F97FF21D47875881214486DB3; rrdLoginCartoon=rrdLoginCartoon; jforumUserInfo=%2BwCK4BqHqXKnB5ElOoVcVwhBlgOTCxhMxGTorrrWCNWleSxhe5xiIJ3l2wYz28xcJUCUKBJE41zt%0AvYRaHHG1KsUaiM2rgbWEx9tmkuZKyTMsRcOSrO6a%2Bg%3D%3D%0A; IS_MOBLIE_IDPASS=true-true; newuser=new
=on&couponId=&agree-contract=on&transferId=ma3q7LyocdI%3D%0D%0A¤tPrice=48.08&share=1&countRatio=0.00
我的VB代碼
PostData = "agree-contract=on&share=1"
XMLHTTP.Open "POST", StrUrl, False
XMLHTTP.setRequestHeader "Accept", "image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/xaml+xml, application/x-ms-xbap, application/x-ms-application, */*"
XMLHTTP.setRequestHeader "Referer", StrUrl
XMLHTTP.setRequestHeader "Accept-Language", "zh-cn"
XMLHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; EmbeddedWB 14.52 from: http://www.bsalsa.com/ EmbeddedWB 14.52; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727)"
XMLHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
XMLHTTP.setRequestHeader "Accept-Encoding", "gzip, deflate"
XMLHTTP.setRequestHeader "Host", "www.we.com"
XMLHTTP.setRequestHeader "Content-Length", Len(PostData)
XMLHTTP.setRequestHeader "Connection", "Keep-Alive"
XMLHTTP.setRequestHeader "Cache-Control", "no-cache"
XMLHTTP.send (PostData)
Do Until XMLHTTP.ReadyState = 4
DoEvents
Loop
不能正確的購買,請問能幫忙修改一下么?謝謝
uj5u.com熱心網友回復:
把cookie加上一般就沒什么問題了uj5u.com熱心網友回復:
好的 謝謝 我再試試
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/82873.html
標籤:網絡編程
