作者:有拼搏精神的芒果tje | 来源:互联网 | 2023-08-14 18:08
像淘宝网这样的登陆界面,程序可否实现自动登陆呢?网址是这个:http:member1.taobao.commemberlogin.jhtml我琢磨了几个小时,似乎有些地方是加密
像淘宝网这样的登陆界面,程序可否实现自动登陆呢?
网址是这个:http://member1.taobao.com/member/login.jhtml
我琢磨了几个小时,似乎有些地方是加密的.
8 个解决方案
用visual Sniffer 测到的..
正常用IE:
?POST /member/login.jhtml HTTP/1.1?POST /member/login.jhtml HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, */*
Referer: http://member1.taobao.com/member/login.jhtml?f=top&redirectURL=http%3A%2F%2Fwww.taobao.com%2F
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon; .NET CLR 2.0.50727)
Host: member1.taobao.com
Content-Length: 232
Connection: Keep-Alive
Cache-Control: no-cache
COOKIE: nt=KpAfzyJU1Crye%2FwkNC82T45CWPUrUNujs7dnSjUBTmKJjB%2F2cZhPP1ayoSBBbxVZadPgKA%3D%3D; ab=86; t=075eb758f145a5860162c13808df1165; wwwtaobaocom_user_from=http%3A%2F%2Fwww.baidu.com%2Fs%3Flm%3D0%26si%3D%26rn%3D10%26ie%3Dgb2312%26ct%3D0%26wd%3D%25B9%25FE%25B6%25FB%25B1%25F5%25B3%25F6%25B0%25E6%25C9%25E7%26pn%3D20%26cl%3D3%26f%3D1; ssllogin=; tracknick=kxlxlk; _cc_=KbSuxTH2Aw%3D%3D; _ad_=KeUKlnfaLNsNJPkOCpMiYgh2b2bpMmlrdoFDNvz%2B5n%2BXME0ts8jG0Eno4N1IYy5COfqJDA%3D%3D; wd=a0c43730e27734a575e9713fe038c06c_0db2%2C8a6ff369777739a805a32838c950bfef_0db2%2Cbd13675045f675a08f41c12ed63470a3_0db2%2C15d7ee344870fae6dc17b044210fdf6a_0db2%2C46785f75c46036d4611b549deec2a4fd_0db2%2Cc3013286134387770a045e6dd2765f08_0db2; yahoo_adinfo=1163219767250; allyes_chsess=109; uc1=COOKIE14=KPi%2FZCexYAlnRQ%3D%3D; COOKIE2=418692eb395a7c4af314c7afac42e293
TPL_username=pppv&TPL_password=sssv&Submit=%B5%C7+%C2%BC&actiOnForStable=enable_post_user_action&action=Authenticator&TPL_redirect_url=http%3A%2F%2Fwww.taobao.com%2F&event_submit_do_login=anything&abtest=0&pstrOng=2&from=
我自已写的程序,再测的结果是:
?POST /member/login.jhtml HTTP/1.1?POST /member/login.jhtml HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: member1.taobao.com
Content-Length: 46
Expect: 100-continue
Connection: Keep-Alive
TPL_username=pppv&TPL_password=sssv
差了好多..
有那么麻烦吗?
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(PageUrl);
request.Accept = @"image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*";
request.KeepAlive = true;
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
request.Headers.Add("Accept-Encoding", "gzip, deflate");
request.Headers.Add("Accept-Language", "zh-cn");
......
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(PageUrl);
request.Accept = @"image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*";
request.KeepAlive = true;
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
request.Headers.Add("Accept-Encoding", "gzip, deflate");
request.Headers.Add("Accept-Language", "zh-cn");
......
程序全部源代码 vb.net 的.. 各位高手看看应该怎么改..
Imports System
Imports System.Net
Imports System.IO
Imports System.Web
Imports System.Text
Public Class testenter
Inherits System.Windows.Forms.Form
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
Select Case rbPost.Checked
Case True
PostData()
Case False
GetData()
End Select
WebBrowser1.DocumentText = txtContent.Text
End Sub
Private Sub PostData()
Dim strURL As String = txtURI.Text
Dim strPost As String
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(strURL), HttpWebRequest)
strPost = "TPL_username=" & txtName.Text & "&" & "TPL_password=" & txtPassword.Text
SetWRProperty(myHttpWebRequest, "POST", strPost.Length, "application/x-www-form-urlencoded", "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, */*", True, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)")
WriteData(myHttpWebRequest, strPost)
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
myCOOKIEsContainer.Add(myHttpWebResponse.COOKIEs)
GetResponseData(myHttpWebResponse.GetResponseStream())
txtSourceUri.Text = myHttpWebRequest.RequestUri.ToString
myHttpWebResponse.Close()
End Sub
Private Sub GetData()
Dim strURL As String = txtURI.Text
Dim myStreamWriter As StreamWriter = Nothing
Dim strGET As String
Dim myHttpWebRequest As HttpWebRequest
strGET = "TPL_username=" & txtName.Text & "&" & "TPL_password=" & txtPassword.Text
myHttpWebRequest = CType(WebRequest.Create(strURL + "?" + strGET), HttpWebRequest)
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
GetResponseData(myHttpWebResponse.GetResponseStream())
txtSourceUri.Text = myHttpWebRequest.RequestUri.ToString
myHttpWebResponse.Close()
End Sub
Private Sub GetResponseData(ByVal myStream As Stream)
Dim myStreamReader As StreamReader = New StreamReader(myStream, Encoding.GetEncoding("gb2312"))
Dim strOut As String = myStreamReader.ReadToEnd()
txtContent.Text = strOut
myStreamReader.Close()
End Sub
Private Sub SetWRProperty(ByRef pHttpWR As HttpWebRequest, ByVal pMethod As String, ByVal pLength As Long, ByVal strType As String, ByVal strAccept As String, ByVal strKeepAlive As Boolean, ByVal strUserAgent As String)
pHttpWR.Method = pMethod
pHttpWR.ContentLength = pLength
pHttpWR.ContentType = strType
pHttpWR.Accept = strAccept
pHttpWR.KeepAlive = strKeepAlive
pHttpWR.UserAgent = strUserAgent
End Sub
Private Sub WriteData(ByRef pHttpWR As HttpWebRequest, ByVal pstrPost As String)
Dim myStreamWriter As StreamWriter = Nothing
myStreamWriter = New StreamWriter(pHttpWR.GetRequestStream())
myStreamWriter.Write(pstrPost)
myStreamWriter.Close()
End Sub
End Class