質問するログイン新規登録

質問編集履歴

7

タグを増やしました

2019/08/01 08:14

投稿

dokidoki_hamuo
dokidoki_hamuo

スコア38

title CHANGED
File without changes
body CHANGED
File without changes

6

不要な見出しの削除

2019/08/01 08:14

投稿

dokidoki_hamuo
dokidoki_hamuo

スコア38

title CHANGED
File without changes
body CHANGED
@@ -1,4 +1,4 @@
1
- ### ヘディングのテキスト### 質問
1
+ ### 質問
2
2
  オライリージャパンから出ている書籍の例文をそのまま打ち込んだのですがエラーになります。
3
3
 
4
4
  SSL認証エラー・プロキシ設定、一応試してみたのですが、うまく作動せずほかの原因を調べてみましたがわかりませんでした。

5

試したことのエラー結果の追記

2019/08/01 07:37

投稿

dokidoki_hamuo
dokidoki_hamuo

スコア38

title CHANGED
File without changes
body CHANGED
@@ -1,4 +1,4 @@
1
- ### 質問
1
+ ### ヘディングのテキスト### 質問
2
2
  オライリージャパンから出ている書籍の例文をそのまま打ち込んだのですがエラーになります。
3
3
 
4
4
  SSL認証エラー・プロキシ設定、一応試してみたのですが、うまく作動せずほかの原因を調べてみましたがわかりませんでした。
@@ -62,4 +62,23 @@
62
62
  self._sslobj.do_handshake()
63
63
  ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)
64
64
 
65
+ ```
66
+ ### 追記---SSL認証した場合のコード
67
+ ```python
68
+
69
+ import requests,os,bs4,ssl
70
+ context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
71
+ res = requests.get('http://nostarch.com',context=context)#ここでエラー
72
+ ```
73
+
74
+ ### 追記---SSL認証した時のエラー
75
+ ```python
76
+ Traceback (most recent call last):
77
+ File "<pyshell#5>", line 1, in <module>
78
+ res = requests.get('http://nostarch.com',context=context)
79
+ 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
80
+ return request('get', url, params=params, **kwargs)
81
+ 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
82
+ return session.request(method=method, url=url, **kwargs)
83
+ TypeError: request() got an unexpected keyword argument 'context'
65
84
  ```

4

プロキシ設定のエラー追加

2019/08/01 07:34

投稿

dokidoki_hamuo
dokidoki_hamuo

スコア38

title CHANGED
File without changes
body CHANGED
@@ -30,4 +30,36 @@
30
30
  ```
31
31
 
32
32
  ### 追記試したこと
33
- SSL認証・プロキシ設定
33
+ SSL認証・プロキシ設定
34
+
35
+ ### 追記---プロキシ設定のコード
36
+ ```python
37
+ import requests,os,bs4,ssl
38
+ proxies = {
39
+ http': 'http://000.00.00.000:12345',
40
+ https': 'http://000.00.00.000:12345',
41
+ }
42
+ res = requests.get('http://nostarch.com', proxies=proxies)#ここを実行したらエラー
43
+
44
+ ```
45
+
46
+ ### 追記--プロキシ設定エラー
47
+ ```python
48
+ Traceback (most recent call last):
49
+ 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
50
+ self._prepare_proxy(conn)
51
+ 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
52
+ conn.connect()
53
+ 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
54
+ ssl_context=context)
55
+ 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
56
+ return context.wrap_socket(sock, server_hostname=server_hostname)
57
+ File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 412, in wrap_socket
58
+ session=session
59
+ File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 853, in _create
60
+ self.do_handshake()
61
+ File "C:\Users\userid123\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 1117, in do_handshake
62
+ self._sslobj.do_handshake()
63
+ ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)
64
+
65
+ ```

3

修正し忘れを直しました

2019/08/01 07:14

投稿

dokidoki_hamuo
dokidoki_hamuo

スコア38

title CHANGED
File without changes
body CHANGED
@@ -1,10 +1,9 @@
1
1
  ### 質問
2
2
  オライリージャパンから出ている書籍の例文をそのまま打ち込んだのですがエラーになります。
3
3
 
4
- 調べてみたら、SSL認証エラーだったようでした。
5
- それからSSLContextを使えば認証方法を設定する事が可能だということがわかったので、いろんなサイトを参考させて頂き設定できました。
6
- ただ、またエラーが出て、こちらは調べてみても解決方法見つかりませんでした。
4
+ SSL認証エラー・プロキシ設定、一応試しみたのですがうまく作動せずほかの原因を調べてみましたかりませんでした。
7
5
 
6
+
8
7
  このエラーの原因がお分かりの方ご回答いただけると助かります。
9
8
 
10
9
  windows10
@@ -31,4 +30,4 @@
31
30
  ```
32
31
 
33
32
  ### 追記試したこと
34
- プロキシ設定をしてやってみましたがだめでした。
33
+ SSL認証・プロキシ設定

2

エラーの場所を追記しました

2019/08/01 07:00

投稿

dokidoki_hamuo
dokidoki_hamuo

スコア38

title CHANGED
File without changes
body CHANGED
@@ -14,7 +14,7 @@
14
14
  ```python
15
15
  import requests,os,bs4,ssl
16
16
  context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
17
- res = requests.get('http://nostarch.com')
17
+ res = requests.get('http://nostarch.com')#ここを実行したらエラー
18
18
  ```
19
19
 
20
20
  ### エラー(修正)

1

ご指摘いただいたことを修正しました

2019/08/01 06:44

投稿

dokidoki_hamuo
dokidoki_hamuo

スコア38

title CHANGED
@@ -1,1 +1,1 @@
1
- HTMLからBeautiflSoupオブジェクト生成したいができない
1
+ HTMLを取得できない
body CHANGED
@@ -10,22 +10,25 @@
10
10
  windows10
11
11
  python 3.7.3
12
12
 
13
- ### 対象のコード
13
+ ### 対象のコード(修正)
14
14
  ```python
15
15
  import requests,os,bs4,ssl
16
16
  context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
17
- res = requests.get('http://nostarch.com',context=context)
17
+ res = requests.get('http://nostarch.com')
18
18
  ```
19
19
 
20
- ### エラー
20
+ ### エラー(修正)
21
21
  ```python
22
22
  Traceback (most recent call last):
23
- File "<pyshell#5>", line 1, in <module>
24
- res = requests.get('http://nostarch.com',context=context)
25
- 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
26
- return request('get', url, params=params, **kwargs)
27
- 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
23
+ 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
28
- return session.request(method=method, url=url, **kwargs)
24
+ (self._dns_host, self.port), self.timeout, **extra_kw)
25
+ 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
26
+ raise err
27
+ 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
28
+ sock.connect(sa)
29
- TypeError: request() got an unexpected keyword argument 'context'
29
+ TimeoutError: [WinError 10060] 接続済みの呼び出し先が一定の時間を過ぎても正しく応答しなかったため、接続できませんでした。または接続済みのホストが応答しなかったため、確立された接続は失敗しました。
30
30
 
31
- ```
31
+ ```
32
+
33
+ ### 追記試したこと
34
+ プロキシ設定をしてやってみましたがだめでした。