Search code examples
pythonpython-2.7urllib2

Unable to fetch url in python


I was not able to fetch url from biblegateway.com here it shows error as urllib2.URLError: <urlopen error [Errno 1] _ssl.c:510: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure> Please don't make duplicate as i went throught the sites which shown in duplicate i didn't understand by visiting that site .

here is my code

import urllib2
url = 'https://www.biblegateway.com/passage/?search=Deuteronomy+1&version=NIV'
response = urllib2.urlopen(url)
html = response.read()
print html

Solution

  • Here is a good reference for fetching url.

    In python 3 you can have:

    from urllib.request import urlopen
    URL = 'https://www.biblegateway.com/passage/?search=Deuteronomy+1&version=NIV'
    f = urlopen(URL)
    myfile = f.read()
    print(myfile)
    

    Not sure it clears a ssl problem though. Maybe some clues here.