I am using urllib to get a string of html from a website and need to put each word in the html document into a list.
Here is the code I have so far. I keep getting an error. I have also copied the error below.
import urllib.request
url = input("Please enter a URL: ")
z=urllib.request.urlopen(url)
z=str(z.read())
removeSpecialChars = str.replace("!@#$%^&*()[]{};:,./<>?|`~-=_+", " ")
words = removeSpecialChars.split()
print ("Words list: ", words[0:20])
Here is the error.
Please enter a URL: http://simleyfootball.com
Traceback (most recent call last):
File "C:Usersjeremy.KLUGMy DocumentsLiClipse WorkspacePython Project 2Module2.py", line 7, in <module>
removeSpecialChars = str.replace("!@#$%^&*()[]{};:,./<>?|`~-=_+", " ")
TypeError: replace() takes at least 2 arguments (1 given)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…