Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用支持JavaScript的内容解析网站_C#_Webclient - Fatal编程技术网

C# 使用支持JavaScript的内容解析网站

C# 使用支持JavaScript的内容解析网站,c#,webclient,C#,Webclient,我想从这里下载所有图片。基本上,我想解析结果字符串,找到指向.jpg的链接并下载这些文件。然而,我得到的代码返回一个html字符串,其中根本没有任何指向jpgs的链接 using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; namespace GetB

我想从这里下载所有图片。基本上,我想解析
结果
字符串,找到指向.jpg的链接并下载这些文件。然而,我得到的代码返回一个html字符串,其中根本没有任何指向jpgs的链接

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace GetBackgrounds
{
    class Program
    {
        static void Main(string[] args)
        {
            string url = "http://support.microsoft.com/en-us/help/18827/places-landscapes-wallpaper";


            string results;

            using (var client = new WebClient())
            {
                client.Headers["User-Agent"] = "Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)";
                results = client.DownloadString(url);
            }
        }
    }
}

由于visual studio中的html预览显示了一个错误,称JavaScript已禁用,我想这与此有关?

您需要一个浏览器组件,因为需要运行JavaScript来填充DOM。查看或检查winforms/WPF窗口上的WebBrowser是否适合您的需要。谢谢,我将对此进行调查