urllib2.HTTPError: HTTP Error 404: Not Found is being returned when i try to execute my Python 2.7 script the full traceback is located at https://pastebin.com/f7EzJ4zn how do i fix this?
site = "https://askubuntu.com"
file_path = site + "/https://askubuntu.com/questions/1156044/what-is-this-
error-typeerror-unsupported-operand-types-for-instance-and/1156049#1156049"
import urllib2
server = urllib2.urlopen(site)
response = urllib2.urlopen(file_path)
print(response.read())
Edit: The problem is solved now i copied the full URL when I needed Urllib2 HTTP 404
site = "https://askubuntu.com"
file_path = "https://askubuntu.com/questions/1156065/urllib2-http-404"
import urllib2
server = urllib2.urlopen(site)
response = urllib2.urlopen(file_path)
print(response.read())
Your URL is incorrect, of course.
That's what a 404 error usually means: Such a file or location does not exist.
In this case, the mistake is obvious: Your "file_path" string is
"https://askubuntu.com/https://askubuntu.com/questions/1156044/what-is-this- error-typeerror-unsupported-operand-types-for-instance-and/1156049#1156049"
and that's clearly not valid. Try it in a web browser and you will see.