Sep-06-2019, 03:28 AM
Hello Everyone,
I'm trying following code, but ending up Authentication Required Error. I'm able to browse the website from browser without any credentials, but not through python script. How can I mitigate this error? Any Help please?
I'm trying following code, but ending up Authentication Required Error. I'm able to browse the website from browser without any credentials, but not through python script. How can I mitigate this error? Any Help please?
from urllib.request import urlopen with urlopen('http://sixty-north.com/c/t.txt') as story: story_words = [] for line in story: line_words = line.decode('utf-8').split() for word in line_words: story_words.append(word) print(story_words)
Error:Traceback (most recent call last):
File "f_test_area.py", line 3, in <module>
with urlopen('http://sixty-north.com/c/t.txt') as story:
File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\request.py", line 223, in urlopen return opener.open(url, data, timeout)
File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\request.py", line 532, in open
response = meth(req, response) File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\request.py", line 642, in http_resp File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\request.py", line 532, in open response = meth(req, response) File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\request.py", line 642, in http_response 'http', request, response, code, msg, hdrs)
File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\request.py", line 570, in error return self._call_chain(*args) File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\request.py", line 504, in _call_chain
result = func(*args) File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)urllib.error.HTTPError: HTTP Error 407: authenticationrequired