質問編集履歴
7
タグを増やしました
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
6
不要な見出しの削除
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
###
|
1
|
+
### 質問
|
2
2
|
|
3
3
|
オライリージャパンから出ている書籍の例文をそのまま打ち込んだのですがエラーになります。
|
4
4
|
|
5
試したことのエラー結果の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
### 質問
|
1
|
+
### ヘディングのテキスト### 質問
|
2
2
|
|
3
3
|
オライリージャパンから出ている書籍の例文をそのまま打ち込んだのですがエラーになります。
|
4
4
|
|
@@ -127,3 +127,41 @@
|
|
127
127
|
|
128
128
|
|
129
129
|
```
|
130
|
+
|
131
|
+
### 追記---SSL認証した場合のコード
|
132
|
+
|
133
|
+
```python
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
import requests,os,bs4,ssl
|
138
|
+
|
139
|
+
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
140
|
+
|
141
|
+
res = requests.get('http://nostarch.com',context=context)#ここでエラー
|
142
|
+
|
143
|
+
```
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
### 追記---SSL認証した時のエラー
|
148
|
+
|
149
|
+
```python
|
150
|
+
|
151
|
+
Traceback (most recent call last):
|
152
|
+
|
153
|
+
File "<pyshell#5>", line 1, in <module>
|
154
|
+
|
155
|
+
res = requests.get('http://nostarch.com',context=context)
|
156
|
+
|
157
|
+
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\lib\site-packages\requests-2.22.0-py3.7.egg\requests\api.py", line 75, in get
|
158
|
+
|
159
|
+
return request('get', url, params=params, **kwargs)
|
160
|
+
|
161
|
+
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\lib\site-packages\requests-2.22.0-py3.7.egg\requests\api.py", line 60, in request
|
162
|
+
|
163
|
+
return session.request(method=method, url=url, **kwargs)
|
164
|
+
|
165
|
+
TypeError: request() got an unexpected keyword argument 'context'
|
166
|
+
|
167
|
+
```
|
4
プロキシ設定のエラー追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -63,3 +63,67 @@
|
|
63
63
|
### 追記試したこと
|
64
64
|
|
65
65
|
SSL認証・プロキシ設定
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
### 追記---プロキシ設定のコード
|
70
|
+
|
71
|
+
```python
|
72
|
+
|
73
|
+
import requests,os,bs4,ssl
|
74
|
+
|
75
|
+
proxies = {
|
76
|
+
|
77
|
+
http': 'http://000.00.00.000:12345',
|
78
|
+
|
79
|
+
https': 'http://000.00.00.000:12345',
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
res = requests.get('http://nostarch.com', proxies=proxies)#ここを実行したらエラー
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
```
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
### 追記--プロキシ設定エラー
|
92
|
+
|
93
|
+
```python
|
94
|
+
|
95
|
+
Traceback (most recent call last):
|
96
|
+
|
97
|
+
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3-1.25.3-py3.7.egg\urllib3\connectionpool.py", line 597, in urlopen
|
98
|
+
|
99
|
+
self._prepare_proxy(conn)
|
100
|
+
|
101
|
+
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3-1.25.3-py3.7.egg\urllib3\connectionpool.py", line 807, in _prepare_proxy
|
102
|
+
|
103
|
+
conn.connect()
|
104
|
+
|
105
|
+
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3-1.25.3-py3.7.egg\urllib3\connection.py", line 370, in connect
|
106
|
+
|
107
|
+
ssl_context=context)
|
108
|
+
|
109
|
+
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3-1.25.3-py3.7.egg\urllib3\util\ssl_.py", line 355, in ssl_wrap_socket
|
110
|
+
|
111
|
+
return context.wrap_socket(sock, server_hostname=server_hostname)
|
112
|
+
|
113
|
+
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 412, in wrap_socket
|
114
|
+
|
115
|
+
session=session
|
116
|
+
|
117
|
+
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 853, in _create
|
118
|
+
|
119
|
+
self.do_handshake()
|
120
|
+
|
121
|
+
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 1117, in do_handshake
|
122
|
+
|
123
|
+
self._sslobj.do_handshake()
|
124
|
+
|
125
|
+
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
```
|
3
修正し忘れを直しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,11 +4,9 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
-
|
7
|
+
SSL認証エラー・プロキシ設定、一応試してみたのですが、うまく作動せずほかの原因を調べてみましたがわかりませんでした。
|
8
8
|
|
9
|
-
それからSSLContextを使えば認証方法を設定する事が可能だということがわかったので、いろんなサイトを参考させて頂き設定できました。
|
10
9
|
|
11
|
-
ただ、またエラーが出て、こちらは調べてみても解決方法が見つかりませんでした。
|
12
10
|
|
13
11
|
|
14
12
|
|
@@ -64,4 +62,4 @@
|
|
64
62
|
|
65
63
|
### 追記試したこと
|
66
64
|
|
67
|
-
プロキシ設定
|
65
|
+
SSL認証・プロキシ設定
|
2
エラーの場所を追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,7 +30,7 @@
|
|
30
30
|
|
31
31
|
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
32
32
|
|
33
|
-
res = requests.get('http://nostarch.com')
|
33
|
+
res = requests.get('http://nostarch.com')#ここを実行したらエラー
|
34
34
|
|
35
35
|
```
|
36
36
|
|
1
ご指摘いただいたことを修正しました
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
HTML
|
1
|
+
HTMLを取得できない
|
test
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
|
24
24
|
|
25
|
-
### 対象のコード
|
25
|
+
### 対象のコード(修正)
|
26
26
|
|
27
27
|
```python
|
28
28
|
|
@@ -30,32 +30,38 @@
|
|
30
30
|
|
31
31
|
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
32
32
|
|
33
|
-
res = requests.get('http://nostarch.com'
|
33
|
+
res = requests.get('http://nostarch.com')
|
34
34
|
|
35
35
|
```
|
36
36
|
|
37
37
|
|
38
38
|
|
39
|
-
### エラー
|
39
|
+
### エラー(修正)
|
40
40
|
|
41
41
|
```python
|
42
42
|
|
43
43
|
Traceback (most recent call last):
|
44
44
|
|
45
|
-
File "
|
45
|
+
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3-1.25.3-py3.7.egg\urllib3\connection.py", line 160, in _new_conn
|
46
46
|
|
47
|
-
|
47
|
+
(self._dns_host, self.port), self.timeout, **extra_kw)
|
48
48
|
|
49
|
-
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\lib\site-packages\r
|
49
|
+
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3-1.25.3-py3.7.egg\urllib3\util\connection.py", line 80, in create_connection
|
50
50
|
|
51
|
-
re
|
51
|
+
raise err
|
52
52
|
|
53
|
-
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\lib\site-packages\r
|
53
|
+
File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3-1.25.3-py3.7.egg\urllib3\util\connection.py", line 70, in create_connection
|
54
54
|
|
55
|
-
|
55
|
+
sock.connect(sa)
|
56
56
|
|
57
|
-
T
|
57
|
+
TimeoutError: [WinError 10060] 接続済みの呼び出し先が一定の時間を過ぎても正しく応答しなかったため、接続できませんでした。または接続済みのホストが応答しなかったため、確立された接続は失敗しました。
|
58
58
|
|
59
59
|
|
60
60
|
|
61
61
|
```
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
### 追記試したこと
|
66
|
+
|
67
|
+
プロキシ設定をしてやってみましたがだめでした。
|