我正在开发一个应用程序,其中使用TTS(文本到语音)转换,并且我想读取Web浏览器内容以将这些文本内容转换为语音。
答案 0 :(得分:0)
您只需编写以下代码:
HttpWebRequest httpReq = (HttpWebRequest)HttpWebRequest.Create(new Uri("https://www.yourURL.com"));
httpReq.BeginGetResponse(HTTPWebRequestCallBack, httpReq);
private void HTTPWebRequestCallBack(IAsyncResult result)
{
string strResponse = "";
try
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
try
{
HttpWebRequest httpRequest = (HttpWebRequest)result.AsyncState;
WebResponse response = httpRequest.EndGetResponse(result);
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream);
strResponse = reader.ReadToEnd();
//do you logic of TTS here
}
catch (Exception ex)
{}
});
}
catch (Exception e)
{}
}
这将获取页面内的所有文本,当然包括HTML标记 如果您想要更专业的方式来获取您的网页中的特定标签 查看以下帖子 http://developer.nokia.com/Community/Wiki/HTML_Page_parsing_using_HTMLAgilityPack