NameError: name 'urllib2' is not defined - Richard Tu's Blog
www.maolintu.com › 2018/01/21 › nameerror-nameJan 21, 2018 · NameError: name ‘urllib2’ is not defined. I am studying mongoDB with python, I met this problem. When I tried to open a url by python, I copied some code from internet like following: import jsonimport urllib2import pymongo# connect to mongoconnection = pymongo.MongoClient("mongodb://localhost")# get a handle to the reddit databasedb = connection.redditstories = db.stories# drop existing collectionstories.drop()# get the reddit home pagereddit_page = urllib2.urlopen("https://www.