C〓〓網面のhtml内容(JSダイナミックで生成されたキャプチャできません)
6813 ワード
キャプチャ内容のコード:
呼び出し方法:
転載先:https://www.cnblogs.com/870060760JR/p/6118024.html
1 ///
2 /// URL
3 ///
4 ///
5 public static string HttpDownloadFile(string url, string path)
6 {
7 try
8 {
9 //
10 HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
11
12 //
13 HttpWebResponse response = request.GetResponse() as HttpWebResponse;
14 // request.GetResponse() Post
15 Stream responseStream = response.GetResponseStream();
16
17 // SourceCode
18 //StreamReader readStream = new StreamReader(responseStream, Encoding.UTF8);
19 //string SourceCode = readStream.ReadToEnd();
20
21 //
22 if (File.Exists(path))
23 {
24 File.Delete(path);
25 }
26 FileStream fs = File.Create(path);
27 fs.Close();
28
29 Stream stream = new FileStream(path, FileMode.Create);
30 byte[] bArr = new byte[1024];
31 int size = responseStream.Read(bArr, 0, (int)bArr.Length);
32 while (size > 0)
33 {
34 stream.Write(bArr, 0, size);
35 size = responseStream.Read(bArr, 0, (int)bArr.Length);
36 }
37 stream.Close();
38 responseStream.Close();
39 return path;
40 }
41 catch (Exception ex)
42 {
43
44 throw ex;
45 }
46
47 }
呼び出し方法:
1 HttpReviceFile.HttpDownloadFile("http://localhost:811/ ", @"D:\Work\Test.xml");
転載先:https://www.cnblogs.com/870060760JR/p/6118024.html