[問題] 請問抓取網頁原始碼有遺失現象

看板C_Sharp (C#)作者 (wind)時間18年前 (2007/09/12 16:21), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
請問我用HttpWebRequest HttpWebResponse 怎麼有些原始碼顯示不出來 就是網頁原始碼中間有缺 但是其中的中文英文都正常顯示"沒有亂碼" (只是會"少抓中間"的一些英文和中文字) 我哪邊寫錯了嗎? 我把Encoding.UTF8改成Encoding.ASCII或Encoding.Default都會少 謝謝 程式如下 private void button4_Click(object sender, EventArgs e) { HttpWebRequest hwRequest = (HttpWebRequest)HttpWebRequest.Create(m_url.Text); HttpWebResponse hwResponse=(HttpWebResponse)hwRequest.GetResponse(); System.IO.StreamReader sr = new System.IO.StreamReader(hwResponse.GetResponse\ Stream(), Encoding.UTF8); int linen=0; string line=""; line = sr.ReadLine(); while (line != null) { textBox2.Text += line+'\r'+'\n'; line = sr.ReadLine(); linen++; } } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 210.69.149.252
文章代碼(AID): #16vw6cKr (C_Sharp)
文章代碼(AID): #16vw6cKr (C_Sharp)