Skip to content

Instantly share code, notes, and snippets.

@fitomad
Created April 19, 2018 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fitomad/4952088e0bb15ecaa515d6f76b90ed4c to your computer and use it in GitHub Desktop.
Save fitomad/4952088e0bb15ecaa515d6f76b90ed4c to your computer and use it in GitHub Desktop.
/*
Usad siempre el inicializador init(contentsOf:encoding:) en lugar
de init(contentsOf:).
Parece que si no especificas una codificación no funciona.
*/
import Foundation
if let url = URL(string: "http://desappstre.com"), let html = try? String(contentsOf: url, encoding: .utf8)
{
print(html)
}
/*
<html>
<head>
<title>desappstre {eStudio}</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
<link href="style/skeleton.css" rel="stylesheet" type="text/css" media="screen">
<link href="style/desappstre.css" rel="stylesheet" type="text/css" media="screen">
...
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment