mlsb.net
当前位置:首页 >> python发送post请求 >>

python发送post请求

使用requests库就可以了: pip install requests payload = {'key1': 'value1', 'key2': 'value2'} r = requests.post("http://httpbin.org/post", data=payload) print(r.text) 然后参考这个网址: http://docs.python-requests.org/en/latest/...

我使用的的python3.5,代码如下: from urllib.parse import urlencodefrom urllib.request import urlopendef send_to_server(url, post_data = None): if post_data: para = urlencode(post_data) page = urlopen(url, para.encode('utf-8')) #...

python发送post和get请求get请求:使用get方式时,请求数据直接放在url中。方法一、import urllibimport urllib2url = "http://192.168.81.16/cgi-bin/python_test/test.py?ServiceCode=aaaa"req = urllib2.Request(url)print reqres_data = url...

import urllib2 import urllib #定义一个要提交的数据数组(字典) data = {} data['username'] = 'zgx030030' data['password'] = '123456' #定义post的地址 url = '' post_data = urllib.urlencode(data) #提交,发送数据 req = urllib2.urlopen...

可以参考如下三种方法: 一、application/x-www-form-urlencoded import urlliburl = "http://www.example.com"body_value = {"package": "com.tencent.lian","version_code": "66" }body_value = urllib.urlencode(body_value)request = urllib...

测试用CGI,名字为test.py,放在apache的cgi-bin目录下:#!/usr/bin/Pythonimport cgidef main():print "Content-type: text/html\n"form = cgi.FieldStorage()if form.has_key("ServiceCode") and form["ServiceCode"].value != "":print " Hello...

import urllib,urllib2url="http://exmaple.com"data={'usename':'username', 'pass':'pass'}para=urllib.urlencode(data)resposne=urllib2.urlopen(url,para)

import urllibimport httplibheaders = {"Content-type": "application/x-www-form-urlencoded; charset=UTF-8","Accept": "*/*"}params = {'username':'xxxx'} data = urllib.urlencode(params) host = '127.0.0.1'url = '/login'conn = httpli...

用这个:class urllib2.Request(url[, data][, headers][, origin_req_host][, unverifiable]) 其中data就是post的内容。 从别的地方找了个例子一看就能懂。 import urllibimport urllib2url = 'http://umbra.nascom.nasa.gov/cgi-bin/eit-catal...

import urllib2 import urllib #定义一个要提交的数据数组(字典) data = {} data['username'] = 'zgx030030' data['password'] = '123456' #定义post的地址 url = 'http://www.test.com/post/' post_data = urllib.urlencode(data) #提交,发送...

网站首页 | 网站地图
All rights reserved Powered by www.mlsb.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com