0

I need to simulate html form submit via python form like this but from sublime text

I try code from that link but it doesn't work for me it give error (No module named 'requests'):

import requests
payload = {'AAAWebView-FormAAA-field1': field1Value, \
    'AAAWebView-FormAAA-field2': field2Value, \
    'NAV__BUTTON__press__AAAWebView-FormAAA-enter': "enter"
}
url="https://host/path1/path2/AdapterHTTP?action_name=myactionWebAction&NEW_SESSION=true"
headers = {'content-type': 'multipart/form-data'}
r = requests.post(url, data=payload, headers=headers, files={})
print r.status_code

I'm absolutely new in python can someone give me a working example

I need to make sublime text plugin to push code from editor to jsfiddle

Community
  • 1
  • 1
David
  • 1,829
  • 20
  • 31

1 Answers1

1

You need to install the Requests library. For example:

pip install requests
TNT
  • 3,392
  • 1
  • 24
  • 27
  • 1
    I don't think so I'll try to create sublime text plugin and it must work without install something like that – David Apr 27 '14 at 16:44
  • 1
    What don't you think? If you want to `import requests` you need to have it. – TNT Apr 27 '14 at 16:56
  • no, I need to use something already I have (sublime text have) – David Apr 27 '14 at 17:15
  • This answer shows a solution without extra libraries: http://stackoverflow.com/a/681182/1547831 (Python2 only) – TNT Apr 27 '14 at 17:36