SwiftSoup icon indicating copy to clipboard operation
SwiftSoup copied to clipboard

how to use SwiftSoup in oc?

Open yueyuedede1 opened this issue 2 years ago • 2 comments

how to use SwiftSoup in oc?

yueyuedede1 avatar Apr 19 '22 16:04 yueyuedede1

Sorry, but what do you mean with oc?

scinfu avatar Apr 20 '22 06:04 scinfu

javascript on/cookie support

I'm new to web stuff, so the question is regarding retrieving price data from https://steamdb.info/app/1063970 by parsing page and looking for key words. But in my case I don't have body data and have messages about turning Javascript on and enabling cookies. Is SwiftSoup a proper tool?

linux, swift-5.6.1-RELEASE

p.s. sorry for not creating a new issue, the button is just grey and I can't push it to create new issue

Chidorin avatar Jul 22 '22 17:07 Chidorin

how to use SwiftSoup in objective-c language

lvyongtao avatar Nov 06 '22 01:11 lvyongtao

You can't directly, you'll need to create a Wrapper. SwiftSoup is a pure Swift library, if we add compatibility with Obj-C we lose compatibility with Linux.

import SwiftSoup
@objc class Wrapper: NSObject {
    @objc static func parseHTML(html: String) -> String {
        let doc: Document = try! SwiftSoup.parse(html)
        return try! doc.text()
    }
}

and

#import "ProjectName-Swift.h"
NSString *txt= [Wrapper parseHTML:@"<html></html>"];

scinfu avatar Jan 10 '23 16:01 scinfu