我想在C#中获取http://validator.w3.org/mobile/check?docAddr=www.facebook.com的内容。这是我的代码:
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.UserAgent = "A .NET Web Crawler";
WebResponse response = request.GetResponse();
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream);
htmlText = reader.ReadToEnd();
代码可以与其他网页一起正常使用,但是http://validator.w3.org/mobile/check?docAddr=www.facebook.com和另外docAddr
代码会给我500错误。我与Fiddler核对,错误是:
HTTP/1.1 500 Internal Server Error
Date: Fri, 03 Jun 2011 22:18:36 GMT
Server: Jigsaw/2.2.6
Content-Length: 59
Content-Type: text/html
Via: 1.1 validator.w3.org
Vary: Accept-Encoding
Connection: close
Servlet has thrown exception:java.lang.NullPointerException
如何解决此问题?