Article from yesterday (20191230)
Today's python error: ModuleNotFoundError: No module named'bs4' https://qiita.com/kaizen_nagoya/items/f0056e5fc735b3ad5783
And finally came out
docker/ubuntu
# python3 wib.py
Traceback (most recent call last):
File "wib.py", line 15, in <module>
url = "https://ja.wikipedia.org/wiki/" + urllib.parse.quote(args[1])
IndexError: list index out of range
This was because no arguments were given at runtime. I finished the work late at night with an article.
Wake up in the morning and search for "Index Error: list index out of range" IndexError: list index out of range error cannot be fixed (beginner) https://teratail.com/questions/166749
With the original article Program change (2) Python3: URL as command line argument (wikipedia) https://qiita.com/kaizen_nagoya/items/fc095b0c580a35001ea7
The original article How to get a list of links from a page from wikipedia https://qiita.com/tadaken3/items/e09ba2ede988bbacb303
If you look at, you can see that args [] is a command line argument, which is given at runtime.
Last night I was so busy writing python that I couldn't even think of the commands at runtime.
docker/ubuntu
# python3 wic.py statistics
Traceback (most recent call last):
File "wic.py", line 15, in <module>
url = "https://ja.wikipedia.org/" + urllib.parse.quote(args[1])
File "/usr/lib/python3.6/urllib/parse.py", line 819, in quote
string = string.encode(encoding, errors)
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 0-5: surrogates not allowed
Try running in English instead of Japanese.
docker/ubuntu
# python3 wic.py hazop
Traceback (most recent call last):
File "wic.py", line 17, in <module>
html = urlopen(url)
File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/usr/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python3.6/urllib/request.py", line 570, in error
return self._call_chain(*args)
File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/usr/lib/python3.6/urllib/request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
Recommended Posts