0

I'm trying to import email_extractor but get an error on the first except statement except urllib2.URLError, detail:

PyCharm message when editing that line says:

"Python 3.6 does not support this syntax"

How can I fix this please?

def getPage(url):
    try:
        f = urllib2.urlopen(url)
        page = ""
        for i in f.readlines():
            page += i
        date = f.info().getdate('Last-Modified')
        if date == None:
            date = (0, 0, 0)
        else:
            date = date[:3]
        f.close()
        return (page, date, f.url)
    except urllib2.URLError, detail:
        pass
        return (None, (0,0,0), "")
Iron Fist
  • 10,739
  • 2
  • 18
  • 34

1 Answers1

0

It is just a wrong syntax with the except block, it should be with parenthesizes :

except (urllib2.URLError, detail):
    pass
    return (None, (0,0,0), "")
Iron Fist
  • 10,739
  • 2
  • 18
  • 34