Python post请求在php页面上显示结果
我想使用python重定向一个最初重定向到其他内容的php页面。 我得到了正确的响应,但是我无法在php页面上看到结果 Python代码: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 +
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+?+数据,新=新