1.获取连接内容
var webGet = new HtmlWeb(); var document = webGet.Load(url); var contentNode = document.DocumentNode;
2.获取某个部分信息
var title = contentNode.SelectSingleNode("/html/body/div[4]/div[1]/h1");
3.获得图片
var imgNodes = imgNodes.SelectNodes(".//img"); foreach (var item in imgNodes) { var imageUrl = item.Attributes["src"]?.Value; if (!string.IsNullOrWhiteSpace(imageUrl)) { imageUrl = "https:" + imageUrl.Replace("https:", "").Replace("http:", ""); var imgurl = FileUploadHelper.DownloadFile(imageUrl); } }