質問編集履歴

2

情報(デバックエリア)の追記

2019/01/18 05:27

投稿

hameji001
hameji001

スコア639

test CHANGED
File without changes
test CHANGED
@@ -176,6 +176,112 @@
176
176
 
177
177
 
178
178
 
179
- P.S.関係ないですが、結果の氏名を画像で返してくるあたりいやらしいですよね(^_^;)
179
+ ~~P.S.関係ないですが、結果の氏名を画像で返してくるあたりいやらしいですよね(^_^;)~~
180
-
180
+
181
- 取得しずらくしているつもりなのかな?
181
+ ~~取得しずらくしているつもりなのかな?~~
182
+
183
+
184
+
185
+ 【追記】
186
+
187
+
188
+
189
+ 肝心の得られた結果を記載していませんでした。
190
+
191
+ ```Swift
192
+
193
+ key: 1efe6c8cf197023f1641ddf9c91bf92
194
+
195
+ response: Optional(<NSHTTPURLResponse: 0x280f515a0> { URL: https://licenseif.mhlw.go.jp/search_isei/jsp/search.do } { Status Code: 200, Headers {
196
+
197
+ "Cache-Control" = (
198
+
199
+ "no-cache"
200
+
201
+ );
202
+
203
+ Connection = (
204
+
205
+ "Keep-Alive"
206
+
207
+ );
208
+
209
+ "Content-Language" = (
210
+
211
+ "ja-JP"
212
+
213
+ );
214
+
215
+ "Content-Length" = (
216
+
217
+ 3420
218
+
219
+ );
220
+
221
+ "Content-Type" = (
222
+
223
+ "text/html;charset=Windows-31J"
224
+
225
+ );
226
+
227
+ Date = (
228
+
229
+ "Fri, 18 Jan 2019 05:21:20 GMT"
230
+
231
+ );
232
+
233
+ Expires = (
234
+
235
+ "Fri, 18 Jan 2019 05:21:20 GMT"
236
+
237
+ );
238
+
239
+ "Keep-Alive" = (
240
+
241
+ "timeout=5, max=100"
242
+
243
+ );
244
+
245
+ Pragma = (
246
+
247
+ "no-cache"
248
+
249
+ );
250
+
251
+ "Set-Cookie" = (
252
+
253
+ "JSESSIONID=D8EBAB81912A6B31218C7C6A4BE3DA96; Path=/search_isei; HttpOnly",
254
+
255
+ "TS0148a66e=01819adb30e42012537fe353de47362bb469da438beb99be39aef16250f355c70dcc11ba00; Path=/",
256
+
257
+ "TS013eb5f3=01819adb304b861905bd8b996036dbf97689182c6641d41ff8eee0131c0c776fd953ef6a92a65e7b3bd9fa491789ade01730b1c3c1; path=/search_isei"
258
+
259
+ );
260
+
261
+ } })
262
+
263
+ data:Optional(3420 bytes)
264
+
265
+ (lldb)
266
+
267
+
268
+
269
+ // となり、以下の行にエラーが吐かれます。
270
+
271
+ let phpOutput = String(data: data!, encoding: .utf8)!
272
+
273
+ Thread 11: Fatal error: Unexpectedly found nil while unwrapping an Optional value
274
+
275
+ ```
276
+
277
+
278
+
279
+ dataに3420 bytesもデータがあるのに、nilが見つかるのは、
280
+
281
+ encodingが間違っているからですか?
282
+
283
+ "Content-Type" = ("text/html;charset=Windows-31J")
284
+
285
+ と返答がくることを考えると、utf8ではなく、
286
+
287
+ windows-31Jでencodeしなきゃいけないと言うことでしょうか?

1

修正1

2019/01/18 05:27

投稿

hameji001
hameji001

スコア639

test CHANGED
File without changes
test CHANGED
@@ -176,6 +176,6 @@
176
176
 
177
177
 
178
178
 
179
- P.S.結果の氏名を画像で返してくるあたりいやらしいですよね(^_^;)
179
+ P.S.関係ないですが、結果の氏名を画像で返してくるあたりいやらしいですよね(^_^;)
180
180
 
181
- 取得しずらくしているのかな?
181
+ 取得しずらくしているつもりなのかな?