我正在尝试在共享托管环境中使用HtmlAgilityPack.Load来解析网页。 但是我在生产页面上收到system.net.sockets.socketexception错误,因为Web主机阻止了连接。
我也在尝试使用Ebay Developer .Net Library
时遇到同样的问题是否有其他选择(除了不同的主机或专用服务器) 我也尝试过WebClient和HttpWebRequest。
HttpWebRequest代码
HttpWebRequest oReq = (HttpWebRequest)WebRequest.Create(url);
resp = (HttpWebResponse)oReq.GetResponse();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
readStream = new StreamReader(resp.GetResponseStream(), encode);
htmlDoc.LoadHtml(readStream.ReadToEnd());
HttpWebRequest的错误消息
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond xxx.xxx.xxx.xxx:80 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.GetResponse()
由于