美文网首页
GET、POST请求

GET、POST请求

作者: 皮修猪 | 来源:发表于2018-04-15 19:23 被阅读0次

HTTP:超文本传输协议,设计的目的是保证客户端于服务端之间的通信。

HTTP的工作方式就是客户端与服务器之间的请求-应答协议。

两种最常见的请求方法就是GET、POST请求。

以下是对GET、POST请求的模拟:

GET:


运用urllib2

import urllib2

req = urllib2.Request(url)

response = urllib2.urlopen(req)

the_page = response.read()


运用requests

import requests

r = requests.get(url, params=params)


POST:


运用urllib, urllib2

import urllib, urllib2

url = "www.xxx.xxx"

values = {.....,

                  .....,

                  ....}

headers = {'xxxxxx':xxxxxx}

data = urllib.urlencode(values)

req = urllib2.Request(url,  data, headers)

reponse = urllib2.urlopen(req)

the_page = reponse.read()


运用requests

import requests

data = {...............}

r = requests.post(url, data=data, headers=headers)


相关文章

  • iOS请求方法和网络安全

    GET和POST请求 GET和POST请求简介 GET请求模拟登陆 POST请求模拟登陆 GET和POST的对比 ...

  • iOS请求方法和网络安全

    GET和POST请求GET和POST请求简介GET请求模拟登陆POST请求模拟登陆GET和POST的对比保存用户信...

  • java发送http请求

    restTemplate get请求 post请求 apache.http.client get请求 post请求...

  • Get和Post的区别

    Get请求和Post请求区别如下: Post请求比Get请求更安全,get请求直接将参数放置在URL中,post请...

  • Okhttp3

    简介 配置 请求思路 get请求思路 post请求思路 get,post 同步和异步请求 异步请求(get) 同步...

  • gf框架 ghttp使用

    案例中包含以下内容 get请求 get请求携带参数 post请求携带参数 post请求发送xml数据 post请求...

  • HttpUtil工具

    HttpUtil工具,http get post请求,https get post请求,ajax response...

  • ajax 请求的时候 get 和 post 方式的区别?

    get和post的区别 get请求不安全,post安全 get请求数据有限制,post无限制 get请求参数会在u...

  • get和post请求区别

    get请求和post请求 差别 get请求回退时无反应,post请求回退时会再次发起请求。 GET请求只能进行ur...

  • iOS 的网络请求案例

    post请求: get请求:

网友评论

      本文标题:GET、POST请求

      本文链接:https://www.haomeiwen.com/subject/ztuucftx.html