TransWikia.com

trying to download json file but i am receving error

Stack Overflow Asked by MusaAb on January 24, 2021

---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
`<ipython-input-8-ae1aafc4db4a> in <module>
      1 import urllib.request
----> 2 source= 
urllib.request.urlopen("http://finance.yahoo.com/webservice/v1/symbols/allcurries/quote?format=json")
      3 pis = source.read()
      4 print(pis)

       ~anaconda3liburllibrequest.py in urlopen(url, data, timeout, 
           cafile, capath, cadefault, context)
    220     else:
    221         opener = _opener
--> 222     return opener.open(url, data, timeout)
    223 
    224 def install_opener(opener):

         ~anaconda3liburllibrequest.py in open(self, fullurl, data, 
            timeout)
    529      for processor in self.process_response.get(protocol, []):
    530             meth = getattr(processor, meth_name)
--> 531             response = meth(req, response)
    532 
    533         return response

         ~anaconda3liburllibrequest.py in http_response(self, 
          request, response)
    639         if not (200 <= code < 300):
    640             response = self.parent.error(
--> 641                 'http', request, response, code, msg, hdrs)
    642 
    643         return response

         ~anaconda3liburllibrequest.py in error(self, proto, *args)
    561             http_err = 0
    562         args = (dict, proto, meth_name) + args
--> 563         result = self._call_chain(*args)
    564         if result:
    565             return result

          ~anaconda3liburllibrequest.py in _call_chain(self, chain, 
          kind, 
              meth_name, *args)
    501         for handler in handlers:
    502             func = getattr(handler, meth_name)
--> 503             result = func(*args)
    504             if result is not None:
    505                 return result

       ~anaconda3liburllibrequest.py in http_error_302(self, req, 
        fp, code, msg, headers)
    753         fp.close()
    754 
--> 755         return self.parent.open(new, timeout=req.timeout)
    756 
    757     http_error_301 = http_error_303 = http_error_307 = 
             http_error_302

           ~anaconda3liburllibrequest.py in open(self, fullurl, 
            data, timeout)
    529     for processor in self.process_response.get(protocol[]):
    530             meth = getattr(processor, meth_name)
--> 531             response = meth(req, response)
    532 
    533                 return response
         ~anaconda3liburllibrequest.py in http_response(self, 
           request, response)
    639     if not (200 <= code < 300):
    640               response = self.parent.error(
--> 641                 'http', request, response, code, msg, hdrs)
    642 
    643         return response

         ~anaconda3liburllibrequest.py in error(self, proto, *args)
    567         if http_err:
    568             args = (dict, 'default', 'http_error_default') + 
               orig_args
--> 569             return self._call_chain(*args)
    570 
    571 # XXX probably also want an abstract factory that knows when it 
             makes

           ~anaconda3liburllibrequest.py in _call_chain(self, 
            chain, kind, meth_name, *args)
    501         for handler in handlers:
    502             func = getattr(handler, meth_name)
--> 503             result = func(*args)
    504             if result is not None:
    505                 return result

           ~anaconda3liburllibrequest.py in 
             http_error_default(self, req, fp, code, msg, hdrs)
    647 class HTTPDefaultErrorHandler(BaseHandler):
    648     def http_error_default(self, req, fp, code, msg, hdrs):
--> 649         raise HTTPError(req.full_url, code, msg, hdrs, fp)
    650 
    65      class HTTPRedirectHandler(BaseHandler):

              HTTPError: HTTP Error 404: Not Found

One Answer

In the stack trace, HTTP Error 404: Not Found indicates the HTTP client could not find the resource.

Possible causes:

  1. there is a typo in the URL http://finance.yahoo.com/webservice/v1/symbols/allcurries/quote?format=json: allcurries => allcurrencies

  2. you did not provide API credentials.

Answered by Pamphile on January 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP