2011-01-18 25 views
1

私はページからHTMLコードをキャプチャしてテキストファイルに配置したいと思います。私は次のエラーを受け取ります:ウェブサイトからhtmlコードをキャプチャ - リモートサーバがエラーを返しました:(407)プロキシ認証が必要です

"リモートサーバーからエラーが返されました:(407)プロキシ認証が必要です。"

誰でもこれを解決する方法を知っていますか?

string url = @"http://www.panalpina.com/www/global/en/tools_resources/unit_converter/currency_codes.html"; 
    HttpWebRequest myWebRequest = (HttpWebRequest)HttpWebRequest.Create(url); 
    myWebRequest.Method = "GET"; 
    // make request for web page 
    myWebRequest.ToString(); 


    HttpWebResponse myWebResponse = (HttpWebResponse)myWebRequest.GetResponse(); 
    StreamReader myWebSource = new StreamReader(myWebResponse.GetResponseStream()); 
    string myPageSource = string.Empty; 
    myPageSource = myWebSource.ReadToEnd(); 
    myWebResponse.Close(); 


    ` 

答えて

1

インターネットに接続するためにプロキシサーバーを使用しているようです。 はいの場合は、httpリクエストの前に次のコードを追加して送信してください。

myWebRequest.Proxy = new WebProxy("you_proxy_machine", 8080 /*port*/); 
myWebRequest.Proxy.Credentials = new NetworkCredential("proxy_username", proxy_password"); 
関連する問題