Daten aus einer Website einlesen

M

Maximilian Hofer

Hallo NG,

zum erstellen einer Anfrag an eine Website benutze ich folgenden Code:


Dim encoding = New System.Text.UTF8Encoding

'Daten zum Posten zusammenbauen

Dim postData As String

postData = "username=" + TextBox1.Text

postData += ("&password=" + TextBox2.Text)

'in ein Byte-Array umwandeln

Dim data() As Byte

data = encoding.GetBytes(postData)

Dim myWebRequest As Net.HttpWebRequest

Dim myWebResponse As Net.HttpWebResponse

'Website zu der die Anfrage gestelt werden soll

myWebRequest =
myWebRequest.Create("https://secure.ycn.com/quickaccess/ycnadsl/phptool.php")

'POST

myWebRequest.Method = "POST"

myWebRequest.ContentType = "application/x-www-form-urlencoded"

myWebRequest.ContentLength = data.Length

Dim NewStream As System.IO.Stream

NewStream = myWebRequest.GetRequestStream()

NewStream.Write(data, 0, data.Length)

NewStream.Close()

'Abschicken...

myWebResponse = myWebRequest.GetResponse()

NewStream = myWebResponse.GetResponseStream()





Das scheint auch zu funktionieren, doch wie kann ich die Daten die mir die
Website zurückliefert z.B. in ein String einlesen?





mfg



MAx
 
C

Cor Ligthert

Maximilian,

Can you show us how and where you use this code and than with in English
please.

Although a major part of the messages (questions and answers) in this
newsgroup is done by non native English speaking people, is the used
language English, will you be so kind to do that as well.

For questions asked in the German Language there are active newsgroups
microsoft.public.de.german.entwickler.dotnet.vb
and when it is entwickler ASP
microsoft.public.de.german.entwickler.dotnet.asp

I hope this helps?

Cor
 
G

Guest

Are you able to translate the original question for us non German speaking
people please Herfried?

Now, if it was in Polish I wouldn't have a problem :)
 
H

Herfried K. Wagner [MVP]

Crouchie,

Crouchie1998 said:
Are you able to translate the original question for us non German speaking
people please Herfried?

The OP wants to download a file from the web and assign the file's content
to a string.
Now, if it was in Polish I wouldn't have a problem :)

:)
 
C

Cor Ligthert

Crouchie,

bez problem

zum erstellen einer Anfrag an eine Website benutze ich folgenden Code:
To fulfil a request from a website do I need the next code

'Website zu der die Anfrage gestelt werden soll
Website where the request will be done

Das scheint auch zu funktionieren, doch wie kann ich die Daten die mir die
Website zurückliefert z.B. in ein String einlesen?

Thas seems as welll to funcion, however how can I get the data that the
Website returns read into a String.


Cor
 
C

Cor Ligthert

Herfried,

You make me curious where did you assume that download, it has something to
do with to get a request using post.

However I see code I don't understand. When I had written this by instance
(with what it was) than I had directly gotten an question fom you from which
language it is. (It is not used in the code by the way)

Dim encoding = New System.Text.UTF8Encoding


Cor
 
H

Herfried K. Wagner [MVP]

Cor Ligthert said:
You make me curious where did you assume that download, it has something
to do with to get a request using post.

Well yes, I meant getting the data returned by the request...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top