2
| using System.Net; using System.IO; |
The function itself looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| public string getHTML( string url) { //Create request for given url HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); //Create response-object HttpWebResponse response = (HttpWebResponse)request.GetResponse(); //Take response stream StreamReader sr = new StreamReader(response.GetResponseStream()); //Read response stream (html code) string html = sr.ReadToEnd(); //Close streamreader and response sr.Close(); response.Close(); //return source return html; } |
A function call could look like this:
1
|
Hiç yorum yok:
Yorum Gönder