Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Cookies and WebClient

  Asked By: Michael    Date: Aug 22    Category: Asp.net    Views: 971
  

i'm trying to make a webclient that fills in a form and gets back webpage
http://vgn.ifilm.com/search/simple/1,3853,,00.html
but this one is using cookies...
How can i get that cookie and pass it again
(i can see the cookie into the headers)

headers:


Transfer-Encoding = chunked
Date = Sun, 09 Mar 2003 16:19:39 GMT
Content-Type = text/html
Proxy-Connection = close
Server = Apache/1.3.6 (Unix)
Set-Cookie = Apache=213.224.83.78.13791047225982448; path=/; expires=Mon,
08-Mar-04 16:06:22 GMT
Via = 1.1 ncgent02 (NetCache NetApp/5.2.1R1D4)

this is my code:

Dim remoteURL As String = TextBox2.Text

' SET PROXY
'
Dim proxyURI As Uri = New Uri("http://proxy.pandora.be:8080")
System.Net.GlobalProxySelection.Select = New System.Net.WebProxy(proxyURI)

'DEFINE WEBCLIENT
'
Dim myWebClient As New System.Net.WebClient()
Dim responseData As [Byte]() = myWebClient.DownloadData(remoteURL)
Dim myString As String = Encoding.ASCII.GetString(responseData)
TextBox1.Text = myString

' GET HEADERS
'
Dim myWebHeaderCollection As WebHeaderCollection = myWebClient.ResponseHeaders

Dim i As Integer
For i = 0 To myWebHeaderCollection.Count - 1
TextBox1.Text += vbCrLF + ControlChars.Tab + myWebHeaderCollection.GetKey(i)
+ " " + ChrW(61) + " " + myWebHeaderCollection.Get(i) + vbCrLf
Next i



HERE I WANNA SCRAPE THE COOKIE

'SEARCH

myWebClient.Headers.Add("Accept", "*/*")
myWebClient.Headers.Add("Accept-Encoding", "gzip,deflate")
myWebClient.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0;
Windows NT 5.1; .NET CLR 1.0.3705)")

Dim form As New NameValueCollection()
Dim SearchPhraseWebClientForm As String = "Shrek"

form.Add("function", "Search")
form.Add("query", SearchPhraseWebClientForm)
form.Add("clmode", "")

I GUESS I HAVE TO PASS THE COOKIE OVERHERE

responseData = myWebClient.uploadValues(remoteURL,"post",form)
myString = Encoding.ASCII.GetString(responseData)
TextBox1.Text += vbCrLf + vbCrLf + myString

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Cookies and WebClient Or get search suggestion and latest updates.




Tagged: