我有一个奇怪的问题。当我得到 httpwebresquest 的响应时,一些数字出现在 html 文本的中间。
例如:
<输入类型=“隐藏”名称=“产品ID”值=“7220701403
841
89620" >
841 是一个不应该出现的数字,因此每隔几行就会出现更多。甚至在一开始:
c04
<html>
<头>
因此,无法解析 html。
UTF8Encoding encoding = new UTF8Encoding();
byte[] bytes = encoding.GetBytes(postDataString);
request.ContentLength = bytes.Length;
request.ContentType = "application/x-www-form-urlencoded";
request.SendChunked = false;
using (Stream writeStream = request.GetRequestStream())
{
writeStream.Write(bytes, 0, bytes.Length);
}
response = (HttpWebResponse)request.GetResponse();
Stream remoteStream = response.GetResponseStream();
byte[] buffer = new byte[65536];
int bytesRead = 0;
do
{
bytesRead = remoteStream.Read(buffer, 0, buffer.Length);
UTF8Encoding enc = new UTF8Encoding();
responseString += enc.GetString(buffer);
} while (bytesRead > 0);
remoteStream.Close();
html 文本位于变量 responseString 中。
感谢您的任何想法和建议。