0

共有ホスティング環境で HtmlAgilityPack.Load を使用して Web ページを解析しようとしています。ただし、Web ホストが接続をブロックするため、本番ページで system.net.sockets.socketexception エラーが発生します。

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()

ありがとう

4

0 に答える 0