Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HTTP error 404
#1
hi there

I was trying to get address by using API, but I got HTTP Error. Does it mean URL I code didn't make sense or only I couldn't get data from the URL?

My code is here.
import urllib.request
import urllib.parse

API = "https://api.aoikujira.com/zip/xml.get.php"

#パラメータをURLエンコードする
values = {
    'fmt' : 'xml',     
    'zn' : '1740064'    
}
params = urllib.parse.urlencode(values)

#リクエスト用のURLを作成
url = API + "?" + params
print("url = ", url)

#ダウンロード
data = urllib.request.urlopen(url).read()
text = data.decode("utf-8")
print(text)


And the Error is this
Error:
url = https://api.aoikujira.com/zip/xml.get.php?fmt=xml&zn=1740064 Traceback (most recent call last): File "download-zip.py", line 18, in <module> data = urllib.request.urlopen(url).read() File "C:\Users\…\Python\Python36-32\lib\urllib\request.py", line 223, in urlopen return opener.open(url, data, timeout) File "C:\Users\…\Python\Python36-32\lib\urllib\request.py", line 532, in open response = meth(req, response) File "C:\Users\…\Python\Python36-32\lib\urllib\request.py", line 642, in http_response 'http', request, response, code, msg, hdrs) File "C:\Users\…\Python\Python36-32\lib\urllib\request.py", line 570, in error return self._call_chain(*args) File "C:\Users\…\Python\Python36-32\lib\urllib\request.py", line 504, in _call_chain result = func(*args) File "C:\Users\…\Python\Python36-32\lib\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
How can I solve it?
Reply


Messages In This Thread
HTTP error 404 - by Karin - May-28-2019, 05:26 AM
RE: HTTP error 404 - by heiner55 - May-28-2019, 05:32 AM
RE: HTTP error 404 - by pixel_chick - May-31-2019, 04:43 AM
RE: HTTP error 404 - by heiner55 - May-31-2019, 01:22 PM
RE: HTTP error 404 - by snippsat - May-31-2019, 02:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  HTTP 404 error with Session Pool Clives 0 1,324 Jun-17-2021, 06:45 PM
Last Post: Clives
  error HTTP Error 403: Forbidden local_bit 1 2,851 Nov-14-2020, 11:34 AM
Last Post: ndc85430
  urllib.error.HTTPError: HTTP Error 404: Not Found ckkkkk 4 8,770 Mar-03-2020, 11:30 AM
Last Post: snippsat
  python beginner HTTP Error 500 leofcastro 0 2,185 Jan-24-2020, 04:37 PM
Last Post: leofcastro
  How to check HTTP error 500 and bypass SriMekala 3 10,599 May-04-2019, 02:07 PM
Last Post: snippsat
  Syntax error for HTTP request GET THX1138 1 6,412 May-12-2018, 12:02 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020