scinfu / SwiftSoup

SwiftSoup: Pure Swift HTML Parser, with best of DOM, CSS, and jquery (Supports Linux, iOS, Mac, tvOS, watchOS)
https://scinfu.github.io/SwiftSoup/
MIT License
4.52k stars 345 forks source link

SwiftSoup.parse is very slow #258

Closed smallgirl closed 9 months ago

smallgirl commented 9 months ago
AF.request("https://api.wogg.xyz/")
            .responseString(queue: .global(qos: .background), encoding: .utf8) { [weak self] response in
                guard let strongSelf = self else {
                    return
                }
                switch response.result {
                case let .success(data):
                    do {
                        print("parse----start")
                        let doc: Document = try SwiftSoup.parse(data)
                        print("parse----finish")

                    } catch {
                        logVerbose(error)
                    }
                case let .failure(error):
                    logVerbose(error)
                }
            }

It took 7 seconds from start to finish of parsing

smallgirl commented 9 months ago

线程问题,切换一个线程就快了。