登录 | 注册 | 忘记密码
首页新闻资讯SEO知识

SEO知识

Python向PHP发起GET与POST请求

来源: 浏览:164次  更新时间:2021-01-08 20:00

Python


CloudBean名目中到PHP开拓WEB控制端,向用Python开拓效劳控制端,PHP在名目中Python的效劳控制端偶尔间须要自动对接PHP的WEB控制端下载大概上传摆设参数大概数据信息,发起此地......

一、Python以GET乞求的办法,GET乞求PHP页面,与并赢得返回值

    print 'aaa'
#!/usr/bin/env python

《Python核心编程 第二版》.(Wesley J. Chun ).[高清PDF华文版]

  echo $_GET["name"];
    print "heelowr"
    res=httpclient.getresponse()
  echo $_GET["pass"];
<?php
  echo $_POST["name"];

2、PHP代码:

except  Exception,e:
Python 的下载地方:请点此地?>
  echo $_POST["pass"];

import httplib,urllib

    httpclient=httplib.HTTPConnection('www.xxx.org',80)
print 'bb'

此地将实行的本领代码进行果然。

在Ubuntu下用Python搭建桌面算法交易探究情况

    print res.status
    headers = {"X-CPU": "arm/x86" , "X-USER": "234299044218541","X-RESOLUTION": "240x320","X-SYSTEM":"2.3","X-LANG":"en-us","X-SIGN":"a1ae6bee406a6b8aa0862969ba49cc1d", "X-IMSI":"3110012345678912","X-COUNTRY":"in","X-TIME":"1335339139"}
#coding=utf8    print res.getheaders()

<span xmlns="http://www.w3.org/1999/xhtml">[root@AY python]#cat /CloudBean/capture.php
except  Exception,e:
    print res.reason

httpclient=None

2、php代码:

</span>

二、Python以Post乞求的办法,POST乞求PHP页面,请求并赢得返回值

    print res.read()
    print res.status

1、Python代码:     

CloudBean名目中到PHP开拓WEB控制端,Python用Python开拓效劳控制端,向在名目中Python的效劳控制端偶尔间须要自动对接PHP的WEB控制端下载大概上传摆设参数大概数据信息,PHP此地采用的本理是Python模仿Http客户端,Python向PHP发起GET与POST请求向PHP地方的Apache倡导Get大概Post乞求。

  echo "GET:";
<?php
    httpclient=httplib.HTTPConnection('www.xxx.org',80)
    params = urllib.urlencode({'name': 'tom', 'pass': 22})

httpclient=None
    res=httpclient.getresponse()
  echo "post";

<span xmlns="http://www.w3.org/1999/xhtml">[root@AY python]#cat /CloudBean/cappost.php
</span>

<span xmlns="http://www.w3.org/1999/xhtml">[root@AY python]#cat httpclientpost.py

Python脚本获得Linux体系信息

</span>#coding=utf8

1、Python代码:

try:

Python 谈话的展开简史

#!/usr/bin/env python

import httplib

Python 的留神引睹:请点此地
    print "error"
try:
    httpclient.request('GET','/CloudBean/capture.php?name=liu&pass=wew')
    httpclient.request('POST','/CloudBean/cappost.php',params,headers)
?>
</span>

    print res.reason

<span xmlns="http://www.w3.org/1999/xhtml">[root@AY python]#cat httpclientget.py
    print res.read()

《Python开拓本领详解》.( 周伟,宗杰).[高清PDF扫描版+随书籍视频+代码]

TAG标签: br Python span print lt gt 控制 PHP echo python strong


文章转载请注明出处:http://hme.rcfle.cn/SEOzhishi-185/23386.html


上一篇:
下一篇:

相关资讯