文法的におかしいところはありますか?
Python
1import csv 2import pandas as pd 3import time 4 5tables = pd.read_html( 6 "https://web.pref.hyogo.lg.jp/kk03/corona_hasseijyokyo.html", header=0 7) 8 9data = tables[0] 10 11data.to_csv("coronaHyogo.csv", index=False) # 出力 12 13time.sleep(7) 14table1 = pd.read_html( 15 "https://web.pref.hyogo.lg.jp/kk03/corona_hasseijyokyo101-150.html" 16) 17time.sleep(2) 18data1 = table1[0] 19time.sleep(2) 20 21table2 = pd.read_html( 22 "https://web.pref.hyogo.lg.jp/kk03/corona_hasseijyokyo53-100.html" 23) 24 25time.sleep(2) 26data2 = table2[0] 27time.sleep(2) 28 29table3 = pd.read_html( 30 "https://web.pref.hyogo.lg.jp/kk03/corona_hasseijyokyo1-52.html" 31) 32time.sleep(2) 33data3 = table3[0] 34time.sleep(2) 35data1.to_csv('C:/Users/detec/Desktop/coronaHyogo.csv', mode='a', header=False) 36time.sleep(5) 37data2.to_csv('C:/Users/detec/Desktop/coronaHyogo.csv', mode='a', header=False) 38time.sleep(5) 39data3.to_csv('C:/Users/detec/Desktop/coronaHyogo.csv', mode='a', header=False) 40time.sleep(5)
error
1Traceback (most recent call last): 2 File "C:\Users\detec\Anaconda3\lib\urllib\request.py", line 1319, in do_open 3 encode_chunked=req.has_header('Transfer-encoding')) 4 File "C:\Users\detec\Anaconda3\lib\http\client.py", line 1252, in request 5 self._send_request(method, url, body, headers, encode_chunked) 6 File "C:\Users\detec\Anaconda3\lib\http\client.py", line 1298, in _send_request 7 self.endheaders(body, encode_chunked=encode_chunked) 8 File "C:\Users\detec\Anaconda3\lib\http\client.py", line 1247, in endheaders 9 self._send_output(message_body, encode_chunked=encode_chunked) 10 File "C:\Users\detec\Anaconda3\lib\http\client.py", line 1026, in _send_output 11 self.send(msg) 12 File "C:\Users\detec\Anaconda3\lib\http\client.py", line 966, in send 13 self.connect() 14 File "C:\Users\detec\Anaconda3\lib\http\client.py", line 1414, in connect 15 super().connect() 16 File "C:\Users\detec\Anaconda3\lib\http\client.py", line 938, in connect 17 (self.host,self.port), self.timeout, self.source_address) 18 File "C:\Users\detec\Anaconda3\lib\socket.py", line 728, in create_connection 19 raise err 20 File "C:\Users\detec\Anaconda3\lib\socket.py", line 716, in create_connection 21 sock.connect(sa) 22TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 23 24During handling of the above exception, another exception occurred: 25 26Traceback (most recent call last): 27 File "corona.py", line 6, in <module> 28 "https://web.pref.hyogo.lg.jp/kk03/corona_hasseijyokyo.html", header=0 29 File "C:\Users\detec\Anaconda3\lib\site-packages\pandas\io\html.py", line 1100, in read_html 30 displayed_only=displayed_only, 31 File "C:\Users\detec\Anaconda3\lib\site-packages\pandas\io\html.py", line 895, in _parse 32 tables = p.parse_tables() 33 File "C:\Users\detec\Anaconda3\lib\site-packages\pandas\io\html.py", line 213, in parse_tables 34 tables = self._parse_tables(self._build_doc(), self.match, self.attrs) 35 File "C:\Users\detec\Anaconda3\lib\site-packages\pandas\io\html.py", line 733, in _build_doc 36 raise e 37 File "C:\Users\detec\Anaconda3\lib\site-packages\pandas\io\html.py", line 714, in _build_doc 38 with urlopen(self.io) as f: 39 File "C:\Users\detec\Anaconda3\lib\site-packages\pandas\io\common.py", line 141, in urlopen 40 return urllib.request.urlopen(*args, **kwargs) 41 File "C:\Users\detec\Anaconda3\lib\urllib\request.py", line 222, in urlopen 42 return opener.open(url, data, timeout) 43 File "C:\Users\detec\Anaconda3\lib\urllib\request.py", line 525, in open 44 response = self._open(req, data) 45 File "C:\Users\detec\Anaconda3\lib\urllib\request.py", line 543, in _open 46 '_open', req) 47 File "C:\Users\detec\Anaconda3\lib\urllib\request.py", line 503, in _call_chain 48 result = func(*args) 49 File "C:\Users\detec\Anaconda3\lib\urllib\request.py", line 1362, in https_open 50 context=self._context, check_hostname=self._check_hostname) 51 File "C:\Users\detec\Anaconda3\lib\urllib\request.py", line 1321, in do_open 52 raise URLError(err) 53urllib.error.URLError: <urlopen error [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond> 54
回答1件
あなたの回答
tips
プレビュー