2014-09-04 4 views
-2

WebClient 메서드를 사용하고 있습니다. 이 사이트에서 특정 데이터가 필요합니다. 그러나 웹 클라이언트는 누락 된 데이터를 다운로드합니다. 나는 메모장에이 사이트를 열어 놓았습니다. +++이 길이는 314497이지만, 웹 클라이언트는 7120 번을 다운로드합니다. 저를 도와주세요.웹 페이지에서 전체 데이터를 다운로드하는 방법

  namespace sampleapp 
      { 
       public partial class Form1 : Form 
       { 
        public Form1() 
        { 
         InitializeComponent(); 
        } 

        private void GetWebText(string url) 
        { 
         HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); 
         request.UserAgent = "A .NET Web Crawler"; 
         WebResponse response = request.GetResponse(); 
         Stream stream = response.GetResponseStream(); 
         StreamReader reader = new StreamReader(stream); 
         string htmlText = reader.ReadToEnd(); 
         textBox1.Text = htmlText; 
         MessageBox.Show(htmlText.Length.ToString()); 


        } 
+0

답장을 보내 주셔서 감사합니다. 그러나 저는 멍청한 뜻으로 이해하지 못합니다 : ( –

답변

0

당신이 비교하고있는 페이지의 HTML 소스는 동일하지 않습니다 :

  using System; 
      using System.Collections.Generic; 
      using System.ComponentModel; 
      using System.Data; 
      using System.Drawing; 
      using System.IO; 
      using System.Linq; 
      using System.Net; 
      using System.Text; 
      using System.Threading.Tasks; 
      using System.Windows.Forms; 

      namespace sampleapp 
      { 
       public partial class Form1 : Form 
       { 
        public Form1() 
        { 
         InitializeComponent(); 
         WebClient webClient = new WebClient(); 
         string data=webClient.DownloadString(new Uri("blablabla")); 
         MessageBox.Show(data.Length.ToString()); 
         textBox1.Text = data; 



        } 

사람은 내가 그것을 처리입니다. 첫 번째 줄에서 doctypes가 동일하지 않다는 것을 알 수 있습니다. 하나는 엄격하고 다른 하나는 과도기적입니다.

문자열 길이가 다른 이유입니다.

URL이 동일한 경우 이는 사용 도구가 통과 중이거나 세션이 지속되지 않는 것일 수 있습니다.

+0

) HttpWebRequest로 답변 해 주셔서 감사합니다. :) –