Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45815 > unrolled thread
| Started by | asianavatar@gmail.com |
|---|---|
| First post | 2013-05-23 08:48 -0700 |
| Last post | 2013-05-24 11:08 -0700 |
| Articles | 7 — 2 participants |
Back to article view | Back to comp.lang.python
Error with python 3.3.2 and https asianavatar@gmail.com - 2013-05-23 08:48 -0700
Re: Error with python 3.3.2 and https Chris Angelico <rosuav@gmail.com> - 2013-05-24 01:56 +1000
Re: Error with python 3.3.2 and https asianavatar@gmail.com - 2013-05-23 09:12 -0700
Re: Error with python 3.3.2 and https Chris Angelico <rosuav@gmail.com> - 2013-05-24 02:18 +1000
Re: Error with python 3.3.2 and https asianavatar@gmail.com - 2013-05-23 10:49 -0700
Re: Error with python 3.3.2 and https Chris Angelico <rosuav@gmail.com> - 2013-05-24 08:23 +1000
Re: Error with python 3.3.2 and https asianavatar@gmail.com - 2013-05-24 11:08 -0700
| From | asianavatar@gmail.com |
|---|---|
| Date | 2013-05-23 08:48 -0700 |
| Subject | Error with python 3.3.2 and https |
| Message-ID | <683480d3-9b36-40f3-af61-e767178ceb87@googlegroups.com> |
I am trying to write a program that requires me hitting a https web link. However, I can't seem to get it to work. The program works fine when dealing with http sites, however, when I try it with a https site I get
socket.gaierror: [Errno 11001] getaddrinfo failed
It seems like it has something to do with the ssl not working, however, I do have the ssl.py in the python library and I have no problem importing it.
My code is below. Any help would be greatly appreciated.
import urllib.request
auth = urllib.request.HTTPSHandler()
proxy = urllib.request.ProxyHandler({'http':'my proxy'})
opener = urllib.request.build_opener(proxy, auth)
f = opener.open('http://www.google.ca/')
[toc] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-05-24 01:56 +1000 |
| Message-ID | <mailman.2019.1369324579.3114.python-list@python.org> |
| In reply to | #45815 |
On Fri, May 24, 2013 at 1:48 AM, <asianavatar@gmail.com> wrote:
> I am trying to write a program that requires me hitting a https web link. However, I can't seem to get it to work. The program works fine when dealing with http sites, however, when I try it with a https site I get
>
> socket.gaierror: [Errno 11001] getaddrinfo failed
>
> It seems like it has something to do with the ssl not working, however, I do have the ssl.py in the python library and I have no problem importing it.
>
> My code is below. Any help would be greatly appreciated.
>
> import urllib.request
> auth = urllib.request.HTTPSHandler()
> proxy = urllib.request.ProxyHandler({'http':'my proxy'})
> opener = urllib.request.build_opener(proxy, auth)
> f = opener.open('http://www.google.ca/')
Check the name of your proxy; maybe you can't resolve it. Can you
identify your proxy by IP address?
By omitting the proxy part, I can quite happily make a direct request
using code like yours.
ChrisA
[toc] | [prev] | [next] | [standalone]
| From | asianavatar@gmail.com |
|---|---|
| Date | 2013-05-23 09:12 -0700 |
| Message-ID | <77525aba-65fc-41c3-aeb5-428d66719bee@googlegroups.com> |
| In reply to | #45816 |
I only have the http of the proxy. I guess I could find out the ip of it. However, even if I use the http proxy address, why would it work for a http site and not a https site if its the proxy that can't resolve.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-05-24 02:18 +1000 |
| Message-ID | <mailman.2021.1369325893.3114.python-list@python.org> |
| In reply to | #45819 |
On Fri, May 24, 2013 at 2:12 AM, <asianavatar@gmail.com> wrote: > I only have the http of the proxy. I guess I could find out the ip of it. However, even if I use the http proxy address, why would it work for a http site and not a https site if its the proxy that can't resolve. Can you post working code for HTTP and nonworking for HTTPS? There was no SSL in the code you posted. Or are you saying it's really just that you change the URL and it stops working? If so, I don't think we can test it without having your proxy... you may want to talk to whoever controls the proxy. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | asianavatar@gmail.com |
|---|---|
| Date | 2013-05-23 10:49 -0700 |
| Message-ID | <f90d099d-e794-4164-b796-4db3a9f95cc5@googlegroups.com> |
| In reply to | #45820 |
Yeah that is the case. Once I change the f = opener.open('website') line to a link that has a https I get that socket error. Nothing else changes. I was reading online and came across this site which shows you how if the version of python installed supports ssl.
http://morlockhq.blogspot.ca/2008/05/python-tip-checking-to-see-if-your.html
When I followed the instructions I got that it wasn't supported, although the ssl.py is in the lib directory. Python was installed from the official python page using the windows installer. Is somehow ssl disabled by default? Do I need to get a third party ssl module?
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-05-24 08:23 +1000 |
| Message-ID | <mailman.2041.1369347839.3114.python-list@python.org> |
| In reply to | #45827 |
On Fri, May 24, 2013 at 3:49 AM, <asianavatar@gmail.com> wrote:
>
> Yeah that is the case. Once I change the f = opener.open('website') line to a link that has a https I get that socket error. Nothing else changes. I was reading online and came across this site which shows you how if the version of python installed supports ssl.
>
> http://morlockhq.blogspot.ca/2008/05/python-tip-checking-to-see-if-your.html
>
> When I followed the instructions I got that it wasn't supported, although the ssl.py is in the lib directory. Python was installed from the official python page using the windows installer. Is somehow ssl disabled by default? Do I need to get a third party ssl module?
Hrm. Unfortunately those instructions don't work for Python 3... or at
least, if they do, then both of my handy installations (one Windows,
one Linux) don't have SSL. However, I *can* do 'import ssl' and
'import _ssl', the latter of which is what Lib/socket.py checks for.
In Python 3.3's Lib/socket.py there's no mention of ssl anywhere, so
I'd be inclined to look elsewhere for support checks.
ChrisA
[toc] | [prev] | [next] | [standalone]
| From | asianavatar@gmail.com |
|---|---|
| Date | 2013-05-24 11:08 -0700 |
| Message-ID | <d0d9303e-4782-4e24-a45f-6458e72aa691@googlegroups.com> |
| In reply to | #45850 |
So apparently switching the http to https in the proxyHandler call did the trick. Thanks for all the help.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web