Web客户端不会在Windows Phone 8.1是否存在?下载网站的HTML [英] WebClient doesn't exist on Windows Phone 8.1? Downloading html of site

查看:155
本文介绍了Web客户端不会在Windows Phone 8.1是否存在?下载网站的HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得一些网站的源代码

I want to get source code of some website.

我发现这个解决方案:

var html = System.Net.WebClient().DownloadString(siteUrl);



不过VisualStudio中告诉Web客户端的System.Net不存在。

But VisualStudio tells that WebClient does not exist in System.Net.

如何解决呢? ?或者如何做到这一点其他的方式

How to fix that? Or how to do it other way?

PS:没有Windows手机都有,当他们寻找一些代码,开发者通常使用一些特殊的标记/解决方案

PS: does windows phone have some special tag which developers usually use when they looking for some code/solutions?

推荐答案

Web客户端并在WP8这样的存在:

WebClient does exist in WP8 like this:

WebClient thisclient = new WebClient();
thisclent.DownloadStringAsync(new Uri("urihere");
thisclient.DownloadStringCompleted += (s, x) =>
{
    if (x.Error != null)
    {
    //Catch any errors
    }
//Run Code
}

有关8.1的应用程序,使用这样的:

For 8.1 apps, use something like this:

    HttpClient http = new System.Net.Http.HttpClient();
    HttpResponseMessage response = await http.GetAsync("somesite");
    webresponse = await response.Content.ReadAsStringAsync();

这篇关于Web客户端不会在Windows Phone 8.1是否存在?下载网站的HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆