func loadData() {
let url = URL(string: "http://www.baidu.com")
URLSession.shared.dataTask(with: url!) { (data, _, error) in
guard let data = data else {
print("网络请求失败 \(String(describing: error))")
return
}
if let html = String(data: data, encoding: .utf8) {
print(html)
}
}.resume()
}
网友评论