You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This snippet was correctly parsed with the latest version of the library. Below is the code snippet and output.
import Foundation
import SwiftSoup
var html = """
<!DOCTYPE html>
<html lang=en-US>
<head>
<meta charset=utf-8><meta content="IE=edge" http-equiv=X-UA-Compatible>
<meta content=unsafe-url name=referrer>
<link href=/images/favicons/favicon--16x16.png rel=icon sizes=16x16 type=image/png>
</head>
<body>
page contents
</body>
</html>
"""
let doc = try SwiftSoup.parse(html)
let metaElements = try doc.select("head *")
for meta in metaElements {
if let attributes = meta.getAttributes() {
print(meta.tagName(), attributes.compactMap { "\($0.getKey())=\($0.getValue())" })
}
}
print(try doc.body()?.text() ?? "–")
meta ["charset=utf-8"]
meta ["content=IE=edge", "http-equiv=X-UA-Compatible"]
meta ["content=unsafe-url", "name=referrer"]
link ["href=/images/favicons/favicon--16x16.png", "rel=icon", "sizes=16x16", "type=image/png"]
page contents
I encountered some pages that were using minify, and the meta and link tags in the head were missing the quotes for the attribute values.
According to WC3, this is permitted part of HTML5 spec for attributes:
https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
Here is a code example which fails:
The text was updated successfully, but these errors were encountered: