I'm attempting to write a script that will allow me to upload an image to BayImg, but I can't seem to get it to work right. As far as I can tell, I'm not getting any result. I don't know if it's not submitting the data or what, but when I print the response, I get the URL of the home page, not the page you get when you upload a picture. If I were using Python 2.x, I would use Mechanize. However, it's not available for Py3k, so I'm attempting to use urllib. I'm using Python 3.2.3. Here is the code:
#!/usr/bin/python3
from urllib.parse import urlencode
from urllib.request import Request, urlopen
image = "/test.png"
removal = "remove"
tags = "python script test image"
url = "http://bayimg.com/"
values = {"code" : removal,
"tags" : tags,
"file" : image}
data = urlencode(values).encode("utf-8")
req = Request(url, data)
response = urlopen(req)
the_page = response.read()
Any assistance would be greatly appreciated.