使用AngleSharp在C#中解析JavaScript网页
发布时间:2020-12-15 08:47:01 所属栏目:百科 来源:网络整理
导读:网页使用 javascript来构建其html所以我需要支持js的html解析器. 我发现了角度锐利,但我不能让它起作用. using AngleSharp;using System;using System.Collections.Generic;using System.Linq;using System.Net;using System.Text;using System.Threading.Ta
网页使用
javascript来构建其html所以我需要支持js的html解析器.
我发现了角度锐利,但我不能让它起作用. using AngleSharp; using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; namespace AngleSharpScraping { class Program { static void Main(string[] args) { GetMkvToolNix(); Console.ReadKey(); } static async void GetMkvToolNix() { // Create a new configuration with javascript interpreter. var config = new Configuration().WithJavaScript(); // Parsing process. var document = await BrowsingContext.New(config).OpenAsync(Url.Create("http://www.fosshub.com/MKVToolNix.html")); var link = document.QuerySelector("body > div.container.page-content > div > div.col-sm-9 > article > div.main-dl-box > p:nth-child(2) > a.dwl-link.xlink").GetAttribute("data"); Console.WriteLine(link); } } } 解决方法
AngleSharp是一个文本解析器.如果你想用JS抓取动态网页,你需要一个无头浏览器.
This answer提供了几个选项(至少一个免费和开源:WebKit.NET). (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ruby-on-rails-3 – 如何在Prawn表中创建粗体标题
- ruby-on-rails – 为多个路由使用相同的控制器?
- C#日历样式的下拉式计算器实例讲解
- Cocos2d-x3.3Final(9)RichText常用成员函数(C++)
- c# – 在Visual Studio Windows Azure模拟器下运行ASP.NET
- ruby-on-rails – Sinatra有ActiveMerchant吗?
- 正则表达式 – grep多个模式单个文件参数列表太长
- vue2.0多条件搜索组件使用详解
- C#中的Internal关键字小结
- 关于JSONObject使用class not found的处理办法