Making a POST call instead of GET using urllib2

This may have been answered before: Python URLLib / URLLib2 POST. Your server is likely performing a 302 redirect from http://myserver/post_service to http://myserver/post_service/. When the 302 redirect is performed, the request changes from POST to GET (see Issue 1401). Try changing url to http://myserver/post_service/.

Need to install urllib2 for Python 3.5.1

WARNING: Security researches have found several poisoned packages on PyPI, including a package named urllib, which will ‘phone home’ when installed. If you used pip install urllib some time after June 2017, remove that package as soon as possible. You can’t, and you don’t need to. urllib2 is the name of the library included in Python 2. You can use the urllib.request library included with … Read more

urllib2 HTTP Error 400: Bad Request

The reason that “the dog” returns a 400 Error is because you aren’t escaping the string for a URL. If you do this: It will work. However I highly suggest you use requests instead of using urllib/urllib2/httplib. It’s much much easier and it’ll handle all of this for you. This is the same code with … Read more

Import error: No module name urllib2

As stated in the urllib2 documentation: The urllib2 module has been split across several modules in Python 3 named urllib.request and urllib.error. The 2to3 tool will automatically adapt imports when converting your sources to Python 3. So you should instead be saying Your current, now-edited code sample is incorrect because you are saying urllib.urlopen(“http://www.google.com/”) instead of just urlopen(“http://www.google.com/”).