Find answers here
Menu
I want to download the source (HTML) of a specific web page, given its complete URL.
// Set the page URL we want to download
let URL = NSURL(string: "https://iswift.org")
// Try downloading it
do {
let htmlSource = try String(contentsOfURL: URL!, encoding: NSUTF8StringEncoding)
print(htmlSource)
}
catch let error as NSError {
print("Ooops! Something went wrong: \(error)")
}
Objective-C to Swift language converter | Visit iSwift Stories
WE CODE.