【问题标题】:How to send data through HTTPS with python? [closed]如何使用 python 通过 HTTPS 发送数据? [关闭]
【发布时间】:2015-11-20 17:02:09
【问题描述】:

我想知道如何在 python 中使用HTTPS 将数据发送到网站。

使用HTTP 似乎很简单,但我无法为HTTPS 请求找到相同的...

【问题讨论】:

  • 你是怎么用http做的?你用https做了什么?
  • 您是否尝试登录特定网站?
  • 我用 urllib2 用 http 发帖。我还没有尝试过使用 https,我确信我必须使用 SSL 之类的东西来让服务器接受我的连接。
  • urllib2 直接支持 https。如their examples section. 所示

标签: python https


【解决方案1】:

requests 非常简单:

import requests
r = requests.get('https://example.com')
print r.status_code

如果要使用urllib2,这里是直接取自their examples的sn-p:

>>> import urllib2
>>> req = urllib2.Request(url='https://localhost/cgi-bin/test.cgi',
...                       data='This data is passed to stdin of the CGI')
>>> f = urllib2.urlopen(req)
>>> print f.read()
Got Data: "This data is passed to stdin of the CGI"

【讨论】:

  • 感谢您的回答。你能告诉我我的数据是否会被加密吗?
  • 只要 URL 以https:// 开头并且网络服务器配置正确,数据就会被加密。
猜你喜欢
  • 1970-01-01
  • 2016-04-11
  • 1970-01-01
  • 2015-02-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-12-06
相关资源
最近更新 更多