Python执行HTTP命令
简而言之,我基本上发现在浏览器地址栏中执行某些字符串会给我带来好处。 例如: http://myip:myport/?CreateOrder=Create+New+Order 在我的数据库中创建一个新订单。
我已经使用 python 设置了我想要传递到该字符串中的变量,但不知道正确的词汇能够准确地计算出如何让 python 执行该字符串,就像它是浏览器一样。
抱歉自己无知。我将不胜感激任何帮助
To be brief, I've basically found that executing certain strings in the address bar in my browser causes good things to happen for me.
For instance: http://myip:myport/?CreateOrder=Create+New+Order creates a new order in my database.
I've used python to set the variables I want passed into that string, but don't know the correct vocab to be able to figure exactly how to get python to execute that string as if it were a browser.
Sorry for being ignorant. I'd appreciate any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然我不确定我是否完全理解您问题的上下文,但您可以使用 在 python 中发出 URL 请求urllib2模块,具体看
urlopen
函数。以下是如何提出您所显示的请求的示例:
While I am not sure that I entirely understand the context of your question you can make URL requests in python using the urllib2 module, specifically look at the
urlopen
function.Here is an example of how you could make the request you showed:
您应该查看
Requests
模块。(httpbin.org 是一个很好的调试 HTTP 请求的服务)
结果:
You should check out the
Requests
module.(httpbin.org is a nice service for debugging HTTP requests)
Result: