Closed samhuangszu closed 6 years ago
@samhuangszu
I'll quote what I've written in PR #26:
Semantically they are the same, however the [property=og:url] selector wont work because it is, strictly speaking, not a valid CSS selector.
HTMLKit parses CSS3 Selectors according to the specification, more specifically the section about Attribute Selectors. An attribute's value is either a CSS String or a CSS Identifier
You should use a valid selector syntax, which is either:
- Quoted: [property='og:url']
- Escaped: [property=og\:url] don't forget to escape the escape in code, i.e.
[property=og\\:url]
Let me know if you mean something else. However this PR should be an issue anyway, so closing it here. Please open an issue next time if you're asking for a feature request.
As I said, this syntax is invalid, that's why it's not supported and that's why I wont implement it.
Take this simple HTML for example:
<html>
<head>
<style>
[property=og:url] { background-color: blue; }
</style>
</head>
<body >
<div property="og:url">Testing</div>
</body>
</html>
And open it a browser. You'll see that the div is not styled. I've just tested it with Chrome, Safari and Firefox. Now change the CSS to: [property='og:url'] { background-color: blue; }
and it works.
Here is a fun fact:
I started implementing HTMLKit
as a port of jsoup
, however I dropped it and started from scratch, because jsoup
is not compliant to the specification and ignores many parts of it.
can suport this css selector [property=og:url]? url: http://www.87wx.net/book/88577/
when i use this selector, can't get the target.
but use jsoup to query, it work.