PC Review


Reply
Thread Tools Rate Thread

Checking website that requires cookies

 
 
beaker
Guest
Posts: n/a
 
      17th Mar 2005
Hello, this is my first foray into the world of web programming, and none of
the searching I've done to solve this problem has left me any the wiser, so
I hope someone out there can help...


What I'm trying to do:

There is a turn based strategy game I play that has a web interface. I want
to write a tool to check my status webpage every so often to see if I have
new turns to play, and go 'beep' and briefly show a pop up if I do - just
like many email clients do with new mail.

Progress so far:

After a bit of Googling and looking at the MSDN I've written a simple method
which will return the source code of a bog standard web page (code below).

Where I got stuck:

The web interface for the game requires me to login. Once logged in,
persistent cookies keep me logged on until I specifically logout. I was
hoping that after logging on in the usual way my method would return the
HTML for my game status page, however instead all I get is the source for
the login page.

Help!:

How do I use cookies so that my application is logged in, and gives me the
source of the page I want? Is this even what I need to do? Or how do I
login fresh each time then get the source? All advice gratefully received.



' Returns HTML source of 'sUrl'.
Public Function Fetch(ByVal sUrl As String) As String

Dim s As String ' Storage for the HTML
Dim buf(8192) As Byte ' Buffer for stream reads

Dim req As HttpWebRequest = CType(WebRequest.Create(sUrl),
HttpWebRequest)
Dim resp As HttpWebResponse = CType(req.GetResponse(),
HttpWebResponse)
Dim respStream As Stream = resp.GetResponseStream()

Dim tempString As String
Dim count As Integer = 0

Do
count = respStream.Read(buf, 0, buf.Length)
If count <> 0 Then
tempString = Encoding.ASCII.GetString(buf, 0, count)
s = s & tempString
End If
Loop While count > 0

Return s

End Function





 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft MVP Activity Requires Checking Mike Williams Microsoft VB .NET 0 26th Apr 2008 09:23 AM
checking for enabled cookies? Jeff Microsoft VB .NET 4 3rd Jan 2007 02:23 AM
Can't access website that requires IWA TRD Windows XP Internet Explorer 0 3rd Apr 2006 04:55 PM
Checking for Session cookies tshad Microsoft ASP .NET 2 16th Jul 2005 02:21 AM
checking whether browser allows cookies in asp.net Ollie Microsoft ASP .NET 3 24th Jul 2004 10:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:56 AM.