Results 1 to 7 of 7

Thread: [2005] HTTP GET Method to a website with Cookie header

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2004
    Posts
    52

    Exclamation [2005] HTTP GET Method to a website with Cookie header

    I am trying to access a website using vb.net. I need to change a couple of headers (mainly the Cookie header). Then I need to get all the HTML contents of the page into one HTML file. How do I go about doing this? I've had problems making it work with HttpWebResponse and using a stream. It keeps telling me that the stream can't be read. It also has problems using GET instead of POST. Can someone help me out?
    -Issa Fram

  2. #2

    Thread Starter
    Member
    Join Date
    Oct 2004
    Posts
    52

    Exclamation Re: [2005] HTTP GET Method to a website with Cookie header

    anyone?
    -Issa Fram

  3. #3

    Arrow Re: [2005] HTTP GET Method to a website with Cookie header

    Can you post the code in question?
    Good Luck,
    Craig - CRG IT Solutions

    *VB.NET Tutorials , HowTos , Books , Helpful Links: Click Here

    *I do not follow threads, so if you have a secondary question, message me.
    *MICROSOFT VB.NET TEAM: Please make Option Strict and Option Explicit ON by default. That is all.

  4. #4

    Thread Starter
    Member
    Join Date
    Oct 2004
    Posts
    52

    Exclamation Re: [2005] HTTP GET Method to a website with Cookie header

    here is the code :

    VB Code:
    1. Dim web1 As HttpWebRequest = CType(WebRequest.Create("http://www.somesite.com/page.php"), HttpWebRequest)
    2. Dim myHttpWebResponse As HttpWebResponse
    3. web1.AllowAutoRedirect = False
    4. web1.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
    5. web1.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/msword, application/x-shockwave-flash, */*"
    6. web1.Headers.Add(HttpRequestHeader.AcceptLanguage, "bg")
    7. web1.KeepAlive = True
    8. web1.Headers.Add(HttpRequestHeader.Cookie, "PHPSESSID=d2b09d04a99bd4e222e13766229ece19")
    9. web1.ContentType = "application/x-www-form-urlencoded"
    10. web1.Method = "GET"
    11. myHttpWebResponse = CType(web1.GetResponse(), HttpWebResponse)
    12. Dim streamResponse As Stream = myHttpWebResponse.GetResponseStream()
    13. Dim streamRead As New StreamReader(streamResponse) 'Error here Message: Stream was not readable
    14. Dim readBuff(256) As [Char]
    15. Dim count As Integer = streamRead.Read(readBuff, 0, 256)
    16. While count > 0
    17.     Dim outputData As New [String](readBuff, 0, count)
    18.     strHTML = strHTML & outputData
    19.     count = streamRead.Read(readBuff, 0, 256)
    20. End While
    21. streamRead.Close()
    22. streamResponse.Close()
    23. myHttpWebResponse.Close()

    all i want to do is access that page and get its HTML contents, but i want to set the PHPSESSID before i access the page. What do i do? Do I use get or is there something wrong with my code? Please help. Thx
    -Issa Fram

  5. #5

    Thread Starter
    Member
    Join Date
    Oct 2004
    Posts
    52

    Exclamation Re: [2005] HTTP GET Method to a website with Cookie header

    a reply with some help would be nice
    -Issa Fram

  6. #6

    Thread Starter
    Member
    Join Date
    Oct 2004
    Posts
    52

    Re: [2005] HTTP GET Method to a website with Cookie header

    did i miss something? cause all of a sudden nobody is helping me out in these forums.
    -Issa Fram

  7. #7

    Arrow Re: [2005] HTTP GET Method to a website with Cookie header

    Have you tried doing the following?
    Code:
    WebRequest.Create("http://www.somesite.com/page.php?PHPSESSID=d2b09d04a99bd4e222e13766229ece19")
    You should be able to remove all that web1 configuration code too.

    This should work for a standard GET request.
    Good Luck,
    Craig - CRG IT Solutions

    *VB.NET Tutorials , HowTos , Books , Helpful Links: Click Here

    *I do not follow threads, so if you have a secondary question, message me.
    *MICROSOFT VB.NET TEAM: Please make Option Strict and Option Explicit ON by default. That is all.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width