免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 11277 | 回复: 2
打印 上一主题 下一主题

Python HTTPS/SSL Windows How To [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-08-02 01:15 |只看该作者 |倒序浏览

HTTPS in the newer versions of Python (2.x and later) is considerably[相当地] easier now. Now it's simply a matter of doing the following:
import httplib
HOSTNAME = 'login.yahoo.com'
conn = httplib.HTTPSConnection(HOSTNAME)
conn.putrequest('GET', '/')
conn.endheaders()
response = conn.getresponse()
print response.read()

For information on how to get SSL working on Windows,check out
Simon Willison's
page.

How to install and setup M2Crypto for the
WinNT environment in three easy steps
M2Crypto will let you retrieve web pages from HTTPS servers. It's great, but it is short on documentation.
Ingredients:
M2Crypto
from Ng Pheng Siong. the Windows
BINARY
package.
OpenSSL
Step 1. Install OpenSSL
Step 1.1 Install OpenSSL DLL files somewhere
This is easy. Just open the the OpenSSL zip file into a directory somewhere on your file system. I put it here:
C:\openssl-0.9.6-win32
It should include these DLLs:
libeay32.dll
ssleay32.dll
Step 1.2 Add the path to the DDLs to system Path environment
Add the directory to your system path. Open "Control Panel | System | Advanced | Environment Variables". Edit the environment variable, Path, to include:
;C:\openssl-0.9.6-win32
Step 2. Install M2Crypto
Step 2.1 Open the m2crypto zip file
Open the zip file m2crypto-0.06-snap6-win32.zip into a package directory m2crypto-0.06-snap6.
Step 2.2 Configure M2Crypto library with Windows specific files.
In the m2crypto-0.06-snap6 package directory find these directories:
M2Crypto/
win/
You need to copy two files from the win directory to the M2Crypto directory. Which files you copy will depend on which version of Python you are using. The win directory will have subdirectories for three versions of Python:
py1/ ......... For Python 1.5.2
py20/ ....... For Python 2.0
py21/ ....... For Python 2.1
Copy all the files from the appropriate directory into the M2Crypto directory.
The M2Crypto directory should now include these files:
_m2crypto.py
_m2cryptoc.dll
Step 2.3 Let Python see the M2Crypto library
This is sort of what would happen if M2Crypto had a distutil (see also the site-module in Python docs). Copy the M2Crypto directory to your Python root directory. For example on my system it would be copied here:
C:\Python21\M2Crypto
Then in your Python root directory create pth file (a text file) called M2Crypto.pth. For example on my system it goes here:
C:\Python21\M2Crypto.pth
The pth file should contain a single line that points to the M2Crypto directory. For example in my pth file it has the following line:
C:\Python21\M2Crypto
Step 3. You're done.
Start up Python and see if it works. From the interpreter type:
import M2Crypto
If this does not return an error then you should be ready to go.


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/8780/showart_149458.html

论坛徽章:
0
2 [报告]
发表于 2011-04-25 00:06 |只看该作者
做个标记,或许会用到

论坛徽章:
0
3 [报告]
发表于 2011-12-06 14:27 |只看该作者
虽然一堆英文没看,但copy下来一运行,我表示很强大
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP