我是使用.NET的WebRequest作为临时黑客“屏幕抓取”自己的页面。.NET WebRequest/WebResponse可以正确转换重音标记,变音标记和实体吗?
这很好,但重音字符和变音字符不能正确翻译。
我想知道是否有一种方法可以使用.NET的许多内置属性和方法正确转换它们。
这里是我用抢的页面代码:
private string getArticle(string urlToGet)
{
StreamReader oSR = null;
//Here's the work horse of what we're doing, the WebRequest object
//fetches the URL
WebRequest objRequest = WebRequest.Create(urlToGet);
//The WebResponse object gets the Request's response (the HTML)
WebResponse objResponse = objRequest.GetResponse();
//Now dump the contents of our HTML in the Response object to a
//Stream reader
oSR = new StreamReader(objResponse.GetResponseStream());
//And dump the StreamReader into a string...
string strContent = oSR.ReadToEnd();
//Here we set up our Regular expression to snatch what's between the
//BEGIN and END
Regex regex = new Regex("<!-- content_starts_here //-->((.|\n)*?)<!-- content_ends_here //-->",
RegexOptions.IgnoreCase);
//Here we apply our regular expression to our string using the
//Match object.
Match oM = regex.Match(strContent);
//Bam! We return the value from our Match, and we're in business.
return oM.Value;
}
对于与问题完全无关的事情发表评论感到抱歉,但是您使用太多评论。认真。 – Chris 2009-04-29 23:29:31