0

may someone please help me what is wrong with my python code below. while running the below code i am getting error as "

Error:
Module object has no attribute 'urlopen' 

Code:

import urllib
u=urllib.urlopen('http://bata.in/bataindia/c-5553_cl-2/men/boots.html')
data = u.read()
f=open('rt22.xml','wb')
f.write(data)
f.close()

Python 3.4 and used VS2014

Thanks a lot

8
  • In Python 3.x, urlopen is located in the request sub module. In short, use from urllib.request import urlopen. Commented Sep 4, 2016 at 11:52
  • @Jim: Thanks Jim, but when i tried to import like this, from urllib.request import urllib....its throwing import type error. like cannot import urllib. please suggest Commented Sep 4, 2016 at 11:59
  • It is from urllib.request import urlopen not from urllib.request import urllib. Commented Sep 4, 2016 at 12:00
  • @Jim: so sorryyyyyyyyy Commented Sep 4, 2016 at 12:01
  • @Jim: name 'urllib' is not defined : Name error occur Commented Sep 4, 2016 at 12:03

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.