Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python post请求在php页面上显示结果_Php_Python_Redirect - Fatal编程技术网

Python post请求在php页面上显示结果

Python post请求在php页面上显示结果,php,python,redirect,Php,Python,Redirect,我想使用python重定向一个最初重定向到其他内容的php页面。 我得到了正确的响应,但是我无法在php页面上看到结果 Python代码: import urllib import urllib2 url = 'http://www.notarealwebsite/test.php' values = {'redirect'='http://www.google.com') data = urllib.urlencode(values) req = urllib2.Request(url +

我想使用python重定向一个最初重定向到其他内容的php页面。 我得到了正确的响应,但是我无法在php页面上看到结果

Python代码:

import urllib
import urllib2

url = 'http://www.notarealwebsite/test.php'
values = {'redirect'='http://www.google.com')

data = urllib.urlencode(values)
req = urllib2.Request(url + "?" + data)
response = urllib2.urlopen(req)
the_page = response.read()

print the_page

import webbrowser
url_2 = "http://www.notarealwebsite/test.php"
new = 2 
webbrowser.open(url,new=new)
PHP代码:/test.PHP

<script>
   function redirect(){
     window.location.replace("?redirect=test5.php");
   }
   setTimeout("redirect()", 5000)
</script>

<?php

   if(isset($_GET['redirect'])){
      $redirect_url = $_GET['redirect'];
      header("Location: " . $redirect_url);
   }
?>
<div>This page will direct in 5 seconds</div>

即使响应是google.com,test.php页面仍然重定向到而不是,请尝试更改Python代码中的以下行: webbrowser.openurl,new=new ==> webbrowser.openurl+?+数据,新=新