2

Here is my code:

import urllib.request
try:
    url = 'https://bitinfocharts.com/comparison/hashrate-btc-dash-sma90.html'

# now, with the below headers, we defined ourselves as a simpleton who is
# still using internet explorer.
    headers = {}
    headers['User-Agent'] = "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.27 Safari/537.17"
    req = urllib.request.Request(url, headers = headers)
    resp = urllib.request.urlopen(req)
    respData = resp.read()

except Exception as e:
    print(str(e))
# Results come out as the follows,
<urlopen error [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:645)>

I used Python 3.5 and have installed pyOpenSSL successfully. I can't figure it out myself.

Bhavesh Odedra
  • 10,990
  • 12
  • 33
  • 58
Tzu Chiang
  • 21
  • 3
  • Which version of OpenSSL you are using? What is the output of `print("%x" % OpenSSL.SSL.OPENSSL_VERSION_NUMBER)` – Steffen Ullrich Dec 22 '15 at 06:59
  • OpenSSL 1.0.2e 3 Dec 2015 – Tzu Chiang Jan 01 '16 at 09:02
  • This site requires SNI. I'm not sure if urllib supports SNI. Try the requests library instead which should support SNI. – Steffen Ullrich Jan 01 '16 at 09:27
  • Many thanks. I will try request library. However, I found a PC that was just installed with Python 3.5 and pyCharm editor works well with that website with the same codes. – Tzu Chiang Jan 02 '16 at 01:17
  • Strange. Are you sure that the OpenSSL version you have given is actually the version used by Python? Because you did not give the version string from Python as I asked for but from the openssl command line. – Steffen Ullrich Jan 02 '16 at 03:49
  • $ print("%x" %OpenSSL.SSL.OPENSSL_VERSION_NUMBER) $ bash: syntax error near unexpected token `"%x"' I used another commend $ openssl version -a – Tzu Chiang Jan 05 '16 at 03:10
  • OpenSSL 1.0.2e 3 Dec 2015 built on: reproducible build, date unspecified – Tzu Chiang Jan 05 '16 at 03:13
  • platform: darwin64-x86_64-cc options: bn(64,64) rc4(ptr,int) des(idx,cisc,16,int) idea(int) blowfish(idx) compiler: clang -I. -I.. -I../include -fPIC -fno-common -DOPENSSL_PIC -DZLIB_SHARED -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM OPENSSLDIR: "/usr/local/etc/openssl" – Tzu Chiang Jan 05 '16 at 03:13
  • The print statement was intended for executing inside Python and not on the command line. It is not relevant which version(s) of OpenSSL you have installed when called from the command line because Python might still be linked against the old 0.9.8 which comes with OS X. – Steffen Ullrich Jan 05 '16 at 05:30

0 Answers0