2

It would be great to get it done without any dependencies.
Here's how I'm currently doing it, but is not working:

data = urllib.parse.urlencode(
            {
                'field':'value',
                'field':'value',
                'field':'value'
            }
        ).encode('utf-8')

req = urllib.request.Request('http://www.example.com', data)

response = opener.open(req).read().decode('utf-8')
user4857867
  • 127
  • 9

1 Answers1

-1

According to documentation and example in there, you do not need to utf-8 encode the data before sending it to Request object.

So try this -

data = urllib.parse.urlencode(
            {
                'field':'value',
                'field':'value',
                'field':'value'
            }
        )

req = urllib.request.Request('http://www.example.com', data)

response = opener.open(req).read()
Anand S Kumar
  • 88,551
  • 18
  • 188
  • 176