urlTextField.text = "http://www.11st.co.kr/product/SellerProductDetail.tmall?method=getSellerProductDetail&prdNo=2736133462"
do {
// let html: String = try String(contentsOf: URL(string: urlTextField.text!)!, encoding: .utf16)
let html = try String(contentsOf: URL(string: urlTextField.text!)!)
let doc: Document = try SwiftSoup.parse(html)
let metaImage: Element? = try doc.head()?.select("meta[property=og:image]").first()
let metaTitle: Element? = try doc.head()?.select("meta[property=og:title]").first()
let image: String? = try metaImage?.attr("content")
let title: String? = try metaTitle?.attr("content")
let html2 = try String.init(contentsOf:URL(string: urlTextField.text!)!)
let doc2: Document = try SwiftSoup.parse(html)
print(doc2)
} catch Exception.Error(let type, let message) {
print(message)
print(type)
} catch {
print("error")
}
error message
Error Domain=NSCocoaErrorDomain Code=264 "The file “SellerProductDetail.tmall” couldn’t be opened because the text encoding of its contents can’t be determined.
When importing html, even if utf8, utf16, and encoding options were not set, html could not be imported.
let html: String = try String(contentsOf: URL(string: urlTextField.text!)!, encoding: .utf8)
let html: String = try String(contentsOf: URL(string: urlTextField.text!)!, encoding: .utf16)
let html: String = try String(contentsOf: URL(string: urlTextField.text!)!, encoding: .utf32)
let html: String = try String(contentsOf: URL(string: urlTextField.text!)!)
all not working
but, i searched encoding : ascii, japaneseeuc~~ working.
text is Chinese;;
but, url is korean site.
data is not korean...
hello Is there any way to get the html encoding not working properly?
it's url "http://www.11st.co.kr/product/SellerProductDetail.tmall?method=getSellerProductDetail&prdNo=2736133462"
this method
error message
Error Domain=NSCocoaErrorDomain Code=264 "The file “SellerProductDetail.tmall” couldn’t be opened because the text encoding of its contents can’t be determined.
When importing html, even if utf8, utf16, and encoding options were not set, html could not be imported.
all not working
but, i searched encoding : ascii, japaneseeuc~~ working. text is Chinese;; but, url is korean site. data is not korean...
How can I get the normal data?