- Home
- Contact
-
Articles / Code
- HTML/CSS (2)
-
Scripts (17)
- Twitter & bash
- Generate sitemaps
- random floating point in bash
- Gmail script
- Python http POST requests
- Bashrc enhancements
- commandline <> nautilus
- Word Definitions
- Synonyms
- mysqld monitor
- remote server
- links and emailaddresses
- Apache Analyser
- remote ipaddress
- OOP Python
- mysql tuning
- diskspace notification
- Server Configuration (6)
- ICT-security (2)
use Python for http POST requests
» Articles / Code » Scripts » use Python for http POST requests
A little script that shows how to use Python for HTTP Requests
import string,urllib
def format(items):
list = []
for k, v in items:
list.append("%s=%s" % (k, urllib.quote_plus(v)))
return string.join(list, '&')
data = { 'hidd':'en', 'email':'you at yourmail.com',
'POST':'post.gif' }
d = format(data.items())
try:
sock = urlopen(YourURL, d)
for l in sock.readlines():
print l
sock.close()
finally:
urlcleanup()
Post your comment
Comments
No one has commented on this page yet.
RSS feed for comments on this page | RSS feed for all comments