+ 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

26th May 2020, 7:12 PM
prasad jagdale
prasad jagdale - avatar
18 Respostas
+ 1
👍
26th May 2020, 7:31 PM
Abhay
Abhay - avatar
+ 1
It is import urllib.request urllib.request.urlopen
26th May 2020, 7:53 PM
Abhay
Abhay - avatar
0
It's urllib.request.urlopen
26th May 2020, 7:24 PM
Abhay
Abhay - avatar
0
I tried that but it wasn't working then as well
26th May 2020, 7:25 PM
prasad jagdale
prasad jagdale - avatar
0
It's working fine ,but you might be getting some errors now because bs4 needs to be installed before using
26th May 2020, 7:27 PM
Abhay
Abhay - avatar
0
I have installed file and extracted as well
26th May 2020, 7:28 PM
prasad jagdale
prasad jagdale - avatar
0
Only one consistent error is module urllib has no attribute urlopen
26th May 2020, 7:29 PM
prasad jagdale
prasad jagdale - avatar
0
So what errors are you getting now?
26th May 2020, 7:29 PM
Abhay
Abhay - avatar
0
Can I tell you later on because I have switched off my pc 😅
26th May 2020, 7:30 PM
prasad jagdale
prasad jagdale - avatar
0
It seems like you're using Python2, not Python 3. Depending which built exactly, you should perhaps use urllib2.urlopen
26th May 2020, 7:34 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
0
I using python 3
26th May 2020, 7:34 PM
prasad jagdale
prasad jagdale - avatar
0
To bd precise I am using python 3.7 😂😂
26th May 2020, 7:35 PM
prasad jagdale
prasad jagdale - avatar
0
I have literally spent hours on this single doubt but I haven't resolved it
26th May 2020, 7:36 PM
prasad jagdale
prasad jagdale - avatar
0
Tried that
26th May 2020, 7:57 PM
prasad jagdale
prasad jagdale - avatar
0
Not working
26th May 2020, 7:57 PM
prasad jagdale
prasad jagdale - avatar
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
26th May 2020, 8:26 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
0
That was an honest mistake
26th May 2020, 8:28 PM
prasad jagdale
prasad jagdale - avatar
0
I am getting error by using input only
26th May 2020, 8:28 PM
prasad jagdale
prasad jagdale - avatar