ivony / jumony Goto Github PK
View Code? Open in Web Editor NEWJumony
License: Apache License 2.0
Jumony
License: Apache License 2.0
Style().SetValue和Style().GetValue方法存在大小写问题,比如:“<层 style="DISPLAY: none; "></层 >”
。Style().GetValue("display")取到的值为null,而Style().GetValue("DISPLAY")取值为none,同样Style().SetValue("DISPLAY","none").SetValue("display", "none")会出现两个值
范例HTML:
<table>
<tr>
<td>
<form>
<!--此处应强行结束form和td以及tr标签-->
<tr>
</tr>
</table>
不知是否支持.net core?
最近在开发windows phone的应用程序,HtmlAgilityPack没办法用CSS或者XPath选择器。
Jumony添加nuget的引用,一运行到相关的代码就报错了。
新版本style不存在的时候Style().GetValue("width")会报错,之前的版本不会
获取类似 style='diaplay: ; width: 12px'的样式时,dom.Style().GetValue("width")取到的值是null而不是12px,而dom.Style().GetValue("diaplay")取到的值是 ; width: 12px而不是空。
说好的.net core呢?现在还没找到一个对.net core支持比较好的解析器。
JumonyParser LoadDocument doesn't work if meta description has "
有没有DEMO什么?
static void test()
{
string strHTML = "<input name="660a3525-b274-2669-591e-8bd04ded968e" title="eeee" id="660a3525-b274-2669-591e-8bd04ded968e" style="border-width: medium medium 1px; border-style: none none solid; border-color: currentColor currentColor rgb(236, 236, 236); left: 149px; top: 73px; width: 100px; height: 20px; text-align: left; color: rgb(0, 0, 0); font-size: 12px; position: absolute; z-index: auto;" type="text" value="" RightKeyGetType="text" DesignerControl="yes" mydefaultvalue="" borderColor="" borderType="1">";
var document = new SystemParser().Parse(strHTML);
string s1 = document.Render();
var inputDoms = document.Find("input");
if (inputDoms != null)
{
foreach (var dom in inputDoms)
{
dom.Style().SetValue("display", null);
}
}
string s2=document.Render();
}
表现: 在调用 Ivony.Html.BaseParser.Parse 方法时, 不抛出异常, 而是无限期不返回.
示例html: 随便找个复杂网页的html 把所有的 > 去掉, 然后parse一下, 大部分能触发该问题.
有些页面要求登入状态,所以请求需要带上cookie.
private void Button_Click_14(object sender, RoutedEventArgs e)
{
var html =
"<body>" +
"<div>" +
"<p><a id='1'>111</a></p>" +
"<span><a id='2'>222</a></span>" +
"<h><a id='3'>333</a></h>" +
"</div>" +
"this is text" +
"<span>" +
"<p><a id='4'>444</a></p>" +
"<span><a id='5'>555</a></span>" +
"<h><a id='6'>666</a></h>" +
"</span>" +
"</body>" +
string.Empty;
var doc = html.ParseAsHtml();
var root = doc.Elements().First();
var e1 = root.Elements();
var e2 = root.Nodes();
var e3 = root.Elements("div,span"); //只返回第一个div#div1
//期望的行为同时是返回 div#div1 和 span#span1
//这个期望行为与 jquery 的 $('body').children('div,span') 一致
var e32 = root.Elements("span,div"); //只返回第一个span#span1
var e4 = root.Find("div,span"); //正常
var e42 = root.Find("span,div"); //正常,与e4结果一致
}
另外选择器的支持貌似还不全面,:root 和 :has 伪类就不受支持,doc.Find(":root") 会抛出异常提示“无法识别的伪类 root”,最麻烦的是 :no(selector) 伪类不支持。其他的伪类也有很多都不支持,下面链接页面中的伪类和其他选择器语法都有不支持的:
①一个小细节了,也可能是 Ivony 的个人习惯,所有的文档都不以句号(。)结尾,部分英文没有使用空格分隔,显得奇怪。
②一些成员应该设计成属性比较合理,但却设计成了方法(虽然属性本质上就是方法=_=),比如 InnerText() 设计成属性会更好,便于使用。
网页地址:http://item.yhd.com/item/1187658_2
测试代码:
var parser = new JumonyParser();
var doc = parser.LoadDocument("http://item.yhd.com/item/1187658_2");
var div = doc.FindFirst(".bigImgList");
Console.WriteLine(div != null ? div.InnerHtml() : "Is Null");
异常提示:
未找到符合选择器 ".bigImgList" 的元素。
因为用于COM 的时候非强签名dll 会报错。
只有这个Ivony.Html.Parser.Regulars.dll 没提供代码,不能自己加签。
用reflector 解码,加签,重新编译替代原来的。没有报错了,但是Find 不到任何东西。太扯了,搞了很久,所以能否提供个强签名的Ivony.Html.Parser.Regulars.dll 。
期待早点支持netcore的版本
对于标签内孤立的引号包裹起来的属性值中出现结束符时,应当解释为标签结束,而不是解释为属性值。
例如
<a href="1" "Test>"> Test</a>
Test后面的>字符应解释为标签结束。
用之前写的例子无法通过。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.