Python:如何在内部/本地发起HTTP请求
我想通过HTTP从我服务器上的一个Python脚本发送一些参数到我服务器上的一个PHP脚本。有什么建议吗?
1 个回答
2
使用 urllib
这个库来做这件事非常简单:
import urllib
myurl = 'http://localhost/script.php?var1=foo&var2=bar'
# GET is the default action
response = urllib.urlopen(myurl)
# Output from the GET assuming response code was 200
data = response.read()