您的位置:首页 > 理论基础 > 计算机网络

python 发送http post请求

2014-01-02 16:10 211 查看
1.新建http.py如下:


import urllib


import urllib2


url = 'http://push.hao123.com/apis/test_send_msg.php'


values = {'g_id':'1027019902',


          'm_time_to_send':'1386049369',


          'm_display':'1',


          'm_push_type':'2'


          ,'m_by_timezone':'0'


          ,'m_msg':'中华人民共和国万岁'


          ,'mt_id':'0',


          'm_iggid_file':'33600458'


         }


data = urllib.urlencode(values)


print data


req = urllib2.Request(url, data)


response = urllib2.urlopen(req)


the_page = response.read()


print the_page



注意以下包含中文,需把文件另存为utf-8格式。
然后执行:python http.py
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: