如何在Windows Phone中下载页面源(HTML) [英] How to download page source (HTML) in Windows Phone
本文介绍了如何在Windows Phone中下载页面源(HTML)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为Windows手机创建一个YouTube视频下载器。为什么我无法下载youtube的页面源(HTML)。我的代码是:
private void Button_Click_1( object sender,RoutedEventArgs e)
{
HttpWebRequest request =(HttpWebRequest)WebRequest.Create(< span class =code-string> http://www.youtube.com);
request.BeginGetResponse( new AsyncCallback(MyFun),request);
}
public void MyFun(IAsyncResult result)
{
HttpWebRequest request =(HttpWebRequest)result.AsyncState;
WebResponse response = request.EndGetResponse(result);
string data = 跨度>;
使用(Stream stream = response.GetResponseStream())
{
StreamReader reader = new StreamReader(stream);
data = reader.ReadToEnd();
}
}
当我使用google.com或除youtube.com之外的任何其他网址时工作正常
解决方案
看看 http://stackoverflow.com/questions/4770864/windows-phone-7-download-pure-html-as-string
I am creating a youtube video downloader for windows phone. Why I am not able to download page source (HTML) of youtube. My Code is:
private void Button_Click_1(object sender, RoutedEventArgs e)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.youtube.com");
request.BeginGetResponse(new AsyncCallback(MyFun), request);
}
public void MyFun(IAsyncResult result)
{
HttpWebRequest request = (HttpWebRequest)result.AsyncState;
WebResponse response = request.EndGetResponse(result);
string data = "";
using (Stream stream = response.GetResponseStream())
{
StreamReader reader = new StreamReader(stream);
data = reader.ReadToEnd();
}
}
It works fine when I use google.com or any other url except youtube.com
解决方案
Take a look at http://stackoverflow.com/questions/4770864/windows-phone-7-download-pure-html-as-string
这篇关于如何在Windows Phone中下载页面源(HTML)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文