0

I'm trying to convert the following cURL command to pycurl but am unable to determine what the equivalent to --data-urlendcode is?

curl --connect-timeout 5 -u usr:pwd --data-urlencode "XML=<setBackground><background><image>http://1.1.1.1/Desktops/320x196x4/grad.png</image><icon> http://1.1.1.1/Desktops/320x196x4/TN-grad.png</icon></background></setBackground>" http://2.2.2.2:80/CGI/Execute
Moonie
  • 55
  • 1
  • 11

2 Answers2

0

there is a urlencoder in the urllib module

so

mydict = {'test1':'att1','test2':'att2'}
my_encoded_list = urlencode(mydict)

creates a dictionary and urlencodes it.

0

Here is the python 3 version. If you are using python 2, please use urllib for request and urlencode.

import urllib
your_dict = {"a": "a", "b": "b"}
res = urllib.request.urlopen(YOUR_URL, urllib.parse.urlencode(your_dict).encode())
# Get the result
print(res.read())
Junyong Yao
  • 689
  • 6
  • 7