1

好的,伙计们,我最近下载了 LiveHTTPHeaders ......我正在尝试编写代码,以便我可以登录到这个网站:http ://stproperty.sg ..这是我现在的代码:

Imports System.Net

导入 System.Text 导入 System.IO

公共课 STclass

Dim logincontainer As CookieContainer
Public Sub check()
    Dim request As HttpWebRequest = DirectCast(WebRequest.Create("http://www.stproperty.sg/p/agent/agentad/indexmode=delete"), HttpWebRequest)
    request.CookieContainer = logincontainer

    Dim response As HttpWebResponse = DirectCast(request.GetResponse, HttpWebResponse)

    Dim reader As New StreamReader(response.GetResponseStream)

    Dim theresult As String = reader.ReadToEnd

    Form1.WebBrowser1.DocumentText = theresult


End Sub
Public Sub delete()

    Dim tempCookies As New CookieContainer

    Dim postdata As String = "tab=active&AdForm%5BPTYTYP%5D=&AdForm%5BLISTYP%5D=&active_check%5B%5D=" & Form1.TextBox2.Text & "&massaction=2"


    Dim enconding As New UTF8Encoding

    Dim byteData As Byte() = enconding.GetBytes(postdata)

    Dim postrequest As HttpWebRequest = DirectCast(WebRequest.Create("http://www.stproperty.sg/p/user/userad/expireListing"), HttpWebRequest)

    postrequest.Method = "POST"
    postrequest.KeepAlive = True
    postrequest.CookieContainer = logincontainer

    postrequest.ContentType = "application/x-www-form-urlencoded"
    postrequest.Host = "www.stproperty.sg"
    postrequest.Referer = "http://www.stproperty.sg/p/user/userad/index"
    postrequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0"


    postrequest.ContentLength = byteData.Length

    Dim postreqstream As Stream = postrequest.GetRequestStream
    postreqstream.Write(byteData, 0, byteData.Length)
    postreqstream.Close()

    Dim postresponse As HttpWebResponse
    postresponse = DirectCast(postrequest.GetResponse, HttpWebResponse)

    'logincontainer.Add(postresponse.Cookies)

    ' logincookie = tempCookies

    Dim postreader As New StreamReader(postresponse.GetResponseStream)
    Dim thepage As String = postreader.ReadToEnd

    Form1.WebBrowser1.DocumentText = thepage


End Sub

Public Sub login()

    Dim tempCookies As New CookieContainer
    Dim browser As String = "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)"

    'get facebook login cookies

    Dim firstrequest As HttpWebRequest = WebRequest.Create("http://sphreg.st701.com/RegAuth2/propertyLogin.html?svc=cpy&goto=http%3A%2F%2Fwww.stproperty.sg%2Faccount%2Fdologin")
    firstrequest.CookieContainer = New CookieContainer
    firstrequest.UserAgent = browser
    Dim firstresponse As HttpWebResponse = firstrequest.GetResponse
    tempCookies.Add(firstresponse.Cookies)






    Dim postData As String = "IDToken1=adrian8nairda%40gmail.com&IDToken2=123456&iPSPCookie=false&goto=http%3A%2F%2Fwww.stproperty.sg%2Faccount%2Fdologin"
    Dim encoding As New UTF8Encoding
    Dim byteData As Byte() = encoding.GetBytes(postData)
    Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("https://sphauth.st701.com/am/UI/Login"), HttpWebRequest)
    postReq.Method = "POST"
    postReq.KeepAlive = True
    postReq.CookieContainer = tempCookies
    postReq.ContentType = "application/x-www-form-urlencoded"
    postReq.Referer = "http://sphreg.st701.com/RegAuth2/propertyLogin.html?svc=cpy&goto=http%3A%2F%2Fwww.stproperty.sg%2Faccount%2Fdologin"

    postReq.Host = "sphauth.st701.com"
    postReq.UserAgent = browser
    postReq.ContentLength = byteData.Length


    'post data to facebook
    Dim postreqstream As Stream = postReq.GetRequestStream()
    postreqstream.Write(byteData, 0, byteData.Length)
    postreqstream.Close()


    'get cookies and store them
    Dim postresponse As HttpWebResponse
    postresponse = DirectCast(postReq.GetResponse(), HttpWebResponse)
    tempCookies.Add(postresponse.Cookies)

    logincontainer = tempCookies

    'check it was all posted correctly
    Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
    Dim thepage As String = postreqreader.ReadToEnd
    Form1.RichTextBox1.Text = thepage
    Form1.WebBrowser1.DocumentText = Form1.RichTextBox1.Text
    Form1.WebBrowser1.ScriptErrorsSuppressed = True
End Sub

结束类

好的..正如你所看到的,我有一个登录功能......我将页面加载到浏览器中,我可以看到浏览和东西..但是当我尝试删除我的一个列表时我不能,我提示登录..即使我将 cookie 存储到 logincontainer 并在尝试删除之前加载它们。有什么帮助吗?

4

0 回答 0