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是否适合您的需要。谢谢,我将对此进行调查