-
-
Save sturdysturge/b73277dc9df70082d2802914b021c7f5 to your computer and use it in GitHub Desktop.
getHTMLSource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
func getHTMLSource() -> String { | |
//Create the URL | |
guard let url = URL(string: "https://apple.com") else { | |
fatalError("Could not create URL") | |
} | |
// Try downloading the HTML source | |
do { | |
return try String(contentsOf: url, encoding: .utf8) | |
} | |
//If there is an error | |
catch let error { | |
fatalError("Failed to download HTML due to error: \(error.localizedDescription)") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment