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
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
相关文章推荐
- RedHat 5.5使用Centos的网络yum源
- 黑马程序员_学习笔记第23天——网络编程TCP/UDP
- 浅谈https\ssl\数字证书
- 【转】判断网络丢包是设备自身问题(路由器为例)
- SDN跟网络虚拟化的完美结合
- SDN跟网络虚拟化的完美结合
- 内容分发网络CDN自结
- socket网络编程
- matlab 通用神经网络代码
- linux 网络子系统
- 基于tcp/udp socket多线程并发实现对二进制协议的压力测试
- jquery获取浏览器高度、宽度和滚动条高度(来自网络)
- Android HttpClient的使用
- Linux中TCP连接过程状态简介
- Openstack中OVS实现GRE网络的GRE数据包分析
- ace TCP 服务端和客户端简单程序
- iOS使用NSURLConnection发送同步和异步HTTP Request
- asp.net后台用HttpWebRequest模拟post提交
- matlab 神经网络训练与仿真 最简单的例子
- uhttpd的实现框架