18 Answers
New Answerimport 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
5/26/2020 7:12:42 PM
prasad jagdale18 Answers
New AnswerIt's working fine ,but you might be getting some errors now because bs4 needs to be installed before using
It seems like you're using Python2, not Python 3. Depending which built exactly, you should perhaps use urllib2.urlopen
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
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message