+ 1
dobt in Scraping HTML Data with BeautifulSoup using python3
import urllib from bs4 import BeautifulSoup url = raw_input('Enter - ') html = urllib.urlopen(url).read() soup = BeautifulSoup(html) tag = soup("span") count=0 sum=0 for i in tag: x=int(i.text) count+=1 sum = sum + x print(count) print(sum) after executing the code i am getting error as( module 'urllib' has no attribute 'urlopen') kindly help me in this matter
18 Respuestas
+ 1
👍
+ 1
It is import urllib.request
urllib.request.urlopen
0
It's urllib.request.urlopen
0
I tried that but it wasn't working then as well
0
It's working fine ,but you might be getting some errors now because bs4 needs to be installed before using
0
I have installed file and extracted as well
0
Only one consistent error is module urllib has no attribute urlopen
0
So what errors are you getting now?
0
Can I tell you later on because I have switched off my pc 😅
0
It seems like you're using Python2, not Python 3. Depending which built exactly, you should perhaps use urllib2.urlopen
0
I using python 3
0
To bd precise I am using python 3.7 😂😂
0
I have literally spent hours on this single doubt but I haven't resolved it
0
Tried that
0
Not working
0
Hmm... then how come you're using raw_input? :)
Check out the link below to see what has changed in which version:
https://docs.python.org/2/library/urllib.html
0
That was an honest mistake
0
I am getting error by using input only