
{"id":19121,"date":"2022-08-17T22:05:04","date_gmt":"2022-08-17T16:35:04","guid":{"rendered":"https:\/\/valavil.in\/?p=19121"},"modified":"2022-08-17T22:05:04","modified_gmt":"2022-08-17T16:35:04","slug":"program-to-post-a-form-using-http-with-requests","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2022\/08\/17\/program-to-post-a-form-using-http-with-requests\/","title":{"rendered":"Program to  POST a form using HTTP with requests"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> \n$cat  form_post_method.py \n#!\/usr\/bin\/env python3\n\nimport requests\n\ndata_dictionary = {'custname': 'customer','custtel': '323232',\n'size': 'large','custemail': 'email@domain.com'}\nresponse = requests.post(\"http:\/\/httpbin.org\/post\",data=data_dictionary)\n\n# we then print out the http status_code\nprint(\"HTTP Status Code: \" + str(response.status_code))\n\nif response.status_code == 200:\n\tprint(response.text)\n$python3  form_post_method.py \nHTTP Status Code: 200\n{\n  \"args\": {}, \n  \"data\": \"\", \n  \"files\": {}, \n  \"form\": {\n    \"custemail\": \"email@domain.com\", \n    \"custname\": \"customer\", \n    \"custtel\": \"323232\", \n    \"size\": \"large\"\n  }, \n  \"headers\": {\n    \"Accept\": \"*\/*\", \n    \"Accept-Encoding\": \"gzip, deflate\", \n    \"Content-Length\": \"72\", \n    \"Content-Type\": \"application\/x-www-form-urlencoded\", \n    \"Host\": \"httpbin.org\", \n    \"User-Agent\": \"python-requests\/2.27.1\", \n    \"X-Amzn-Trace-Id\": \"Root=1-62fd14b6-46c6b0b363ae1c7571b8c3f0\"\n  }, \n  \"json\": null, \n  \"origin\": \"27.57.31.195\", \n  \"url\": \"http:\/\/httpbin.org\/post\"\n}\n\n$       \n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>$cat form_post_method.py #!\/usr\/bin\/env python3 import requests data_dictionary = {&#8216;custname&#8217;: &#8216;customer&#8217;,&#8217;custtel&#8217;: &#8216;323232&#8217;, &#8216;size&#8217;: &#8216;large&#8217;,&#8217;custemail&#8217;: &#8217;email@domain.com&#8217;} response = requests.post(&#8220;http:\/\/httpbin.org\/post&#8221;,data=data_dictionary) # we then print out the http status_code print(&#8220;HTTP Status Code: &#8221; + str(response.status_code)) if response.status_code == 200: print(response.text) $python3 form_post_method.py HTTP Status Code: 200 { &#8220;args&#8221;: {}, &#8220;data&#8221;: &#8220;&#8221;, &#8220;files&#8221;: {}, &#8220;form&#8221;: { &#8220;custemail&#8221;: &#8220;email@domain.com&#8221;, &#8220;custname&#8221;: &#8220;customer&#8221;, &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2022\/08\/17\/program-to-post-a-form-using-http-with-requests\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Program to  POST a form using HTTP with requests&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/19121"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=19121"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/19121\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=19121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=19121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=19121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}