Skip to content Skip to sidebar Skip to footer

How To Get Html Source From Url In Swift Anonymously?

I am trying to scrape html code from a URL using Swift, but it needs to be done anonymously. The issue with my case is that the content differs when I am logged in the website or

Solution 1:

It will always do this anonymously :

var request = URLRequest(url: URL(string: "http://google.com")!)
request.httpMethod = "GET"
let session = URLSession.init(configuration: URLSessionConfiguration.default)
session.dataTask(with: request) {data,response,error in
    if let data = data {
       let contents = String(data: data, encoding: .ascii)
    }
}.resume()

Post a Comment for "How To Get Html Source From Url In Swift Anonymously?"