Using Swift, How can I get the HTML code of a webpage? I have read on HTTP requests but I can not understand how to apply them to get the HTML code. Does anyone know how to do this?
EDIT: There is no work solution in the suggested same question.
This should do the trick: (optimized with objective-c)
Url = NSURL (string: "http://www.example.com") error var: NSError? HTML = NSString (contentOfURL: url !, encoding: NSUTF8StringEncoding, error: and error) If (error! = Zero) {println ("Whoops, something went wrong")} {println (html!)}
Comments
Post a Comment