SSL(HTTPS)与2.4 [英] SSL (HTTPS) with 2.4

查看:65
本文介绍了SSL(HTTPS)与2.4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。


前段时间(几年),我在Python 2.2上有一个脚本,可以用来回复一个

HTTPS网站。我使用python22-win32-ssl.zip来处理SSL方面

并且它运行得非常好。我正在重新审视该项目,需要将
更新为Python 2.4.1。 python22-win32-ssl.zip是不兼容

(duh)我找不到更新的版本。我有一个搜索,但是不能找到任何可以指向正确方向的东西。


有人可以帮忙吗?
< br>

Hi all.

Some time ago (years) I had a script on Python 2.2 that would retieve a
HTTPS web site. I used python22-win32-ssl.zip to handle the SSL aspect
and it worked wonderfully. I am revisiting the project and need to
update it to Python 2.4.1. python22-win32-ssl.zip isn''t compatable
(duh) and I can''t find a newer version. I have had a search and can''t
find anything to point me in the right direction.

Can someone please help?

推荐答案

Bloke写道:
前段时间(几年)我在Python 2.2上有一个脚本可以解析一个
HTTPS网站。我使用python22-win32-ssl.zip来处理SSL方面
并且它运行得非常好。我正在重新审视该项目,需要将其更新为Python 2.4.1。 python22-win32-ssl.zip是不兼容
(duh),我找不到更新的版本。我有一个搜索,不能找到任何指向正确方向的东西。

有人可以帮忙吗?
Some time ago (years) I had a script on Python 2.2 that would retieve a
HTTPS web site. I used python22-win32-ssl.zip to handle the SSL aspect
and it worked wonderfully. I am revisiting the project and need to
update it to Python 2.4.1. python22-win32-ssl.zip isn''t compatable
(duh) and I can''t find a newer version. I have had a search and can''t
find anything to point me in the right direction.

Can someone please help?




在Python 2.4中,你不需要任何额外的库就可以在HTTP客户端上使用SSL来实现SSL - Python 2.4附带了SSL(IIRC,你这个
在Python 2.2中也不需要这些库。


只需使用httplib.HTTPS或httplib.HTTPSConnection。


此致,

Martin



In Python 2.4, you don''t need any additional libraries to do SSL on
the HTTP client side - Python 2.4 comes with SSL included (IIRC, you
didn''t need these libraries in Python 2.2, either).

Just use httplib.HTTPS or httplib.HTTPSConnection instead.

Regards,
Martin


感谢Martin。这意味着我的代码应该可以工作。


我正在尝试通过代理,这对HTTP站点工作正常。

然而,当我尝试HTTPS时网站,该程序没有回应相当

a,并返回错误:


"文件C:\Python24 \lib \urllib2.py,第996行,在do_open中

提升URLError(错误)

URLError:< urlopen错误(8,''EOF违反协议'')>"


这是我的测试代码:


import urllib2


proxy_info = {

''用户'''''我'',

''传递'':' 'mypassword'',

''host'':''proxy.mycompany.com'',

''port'':8008}#settings from web浏览器

#构建一个使用需要授权的代理的新开启者

proxy_support =

urllib2.ProxyHandler({" https":" https://%(user)s:%(pass)s @%(host)s:%(port)d"

%proxy_info})

opener = urllib2.build_opener(proxy_support,urllib2.HTTPHandler)


#安装它

urllib2.install_opener(开启者)


#用它

f = urllib2.urlope n(''https://www.directshares.com.au'')

打印f.headers

f.close()

任何想法有什么问题?


Bloke

Thanks Martin. That means my code should work.

I am trying to go through a proxy, which works fine for HTTP sites.
However, when I try a HTTPS site, the program doesn''t respond for quite
a while, and returns the error:

" File "C:\Python24\lib\urllib2.py", line 996, in do_open
raise URLError(err)
URLError: <urlopen error (8, ''EOF occurred in violation of protocol'')>"

Here is my testing code:

import urllib2

proxy_info = {
''user'' : ''me'',
''pass'' : ''mypassword'',
''host'' : ''proxy.mycompany.com'',
''port'' : 8008 } # settings taken from web browser
# build a new opener that uses a proxy requiring authorization
proxy_support =
urllib2.ProxyHandler({"https":"https://%(user)s:%(pass)s@%(host)s:%(port)d"
% proxy_info})
opener = urllib2.build_opener(proxy_support, urllib2.HTTPHandler)

# install it
urllib2.install_opener(opener)

# use it
f = urllib2.urlopen(''https://www.directshares.com.au'')
print f.headers
f.close()

Any ideas what is wrong?

Bloke


我刚刚删除了我的Python安装2.4.1,这是python.org网站上的b $ b。我安装了Activepython 2.4.1,现在我使用上面相同的代码得到以下错误:


文件" C:\Python24 \ lib \urllib2.py",第1053行,在unknown_open中

提升URLError(''未知网址类型:%s''%类型)

URLError:< urlopen错误未知网址类型:https>


我有点沮丧。我是否需要导入另一个图书馆?

任何建议都表示赞赏。


Bloke。

I just removed my installation of Python 2.4.1, which was the one on
the python.org web site. I installed the Activepython 2.4.1 and now I
get the following error with the same code above:

File "C:\Python24\lib\urllib2.py", line 1053, in unknown_open
raise URLError(''unknown url type: %s'' % type)
URLError: <urlopen error unknown url type: https>

I''m getting a bit frustrated. Do I need to import another library?
Any advise is appreciated.

Bloke.

这篇关于SSL(HTTPS)与2.4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆