Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let config = WKWebViewConfiguration()
- //let headlessWebView = self.browserWebview
- //self.centerBrowserWebViewConstraint.constant = 0
- //self.browserWebview.isHidden = false
- let headlessWebView = WKWebView(frame: .zero, configuration: config)
- headlessWebView.isHidden = true
- var request = URLRequest(url: URL(string: "https://www.supremenewyork.com/checkout")!)
- request.setValue("Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1", forHTTPHeaderField: "user-agent")
- request.setValue("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", forHTTPHeaderField: "accept")
- request.setValue("gzip, deflate, br", forHTTPHeaderField: "accept-encoding")
- request.setValue("en-US,en;q=0.9", forHTTPHeaderField: "accept-language")
- let newCookies = cookie.replacingOccurrences(of: "request_method=POST;", with: "").replacingOccurrences(of: "HttpOnly", with: "").replacingOccurrences(of: "-0000,", with: "-0000;")
- request.setValue(newCookies, forHTTPHeaderField: "cookie")
- headlessWebView.load(request)
- headless.browsers.append(headlessWebView)
- let indexOfBrowser = (headless.browsers.firstIndex(of: headlessWebView))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement