Avatar
Swift 勉強しようと思い、手元にあるURLリスト(1,000 ドメインくらい) をクローリングするコードを書いて見たのですが、数件取得したのちに A server with the specified hostname could not be found のようにエラーが出てしまい、curl ではアクセスできるURLでもうまくクローリングできません。 何かネットワークの設定などが必要でしょうか? https://gist.github.com/dictav/52e180d8f449912a0c8fe77d53f61b1c URLSession を使っています。 session.dataTask(with: URLRequest(url: self.url)) { (data, response, error) in defer { self.isExecuting = false self.isFinished = true } if let err = error { print(self.url, err.localizedDescription) return } if let res = response as? HTTPURLResponse { print("status: \(res.statusCode)") } }.resume() (edited)
GitHub Gist: instantly share code, notes, and snippets.